1.0.17 • Published 2 years ago

render-markdown-tables v1.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

What

This is a package for rendering GitLab flavored markdown tables in the browser.

Why

Maybe your CMS doesn't support tables, but you REALLY need a way to render some of your content as tables. Maybe you just have lot of tables and would prefer to write

<pre>
| Price | Quantity |
| :---- | -------: |
|   $5  |    42    |
|   $7  |    21    |
</pre>

in your HTML instead of dealing with <th> and <tr> and <td> tags.

Installation

With a CDN

import { isMarkdownTable, renderMarkdownTable } from "https://esm.sh/render-markdown-tables@1.0.17"

With NPM

npm install render-markdown-tables

Usage

<!DOCTYPE html>
<html>
  <style>
    table {
      border-collapse: collapse;
    }

    td,
    th {
      border: 1px solid black;
    }
  </style>
  <body>
    <pre class="md-table">
| Price | Quantity |
| :---- | -------: |
|   $5  |    42    |
|   $7  |    21    |
    </pre>
    <pre class="md-table">
| Fruit  | Color  |
| :----: | :----: |
| apple  |  red   |
| orange | orange |
| banana | yellow |
    </pre>
  </body>
  <script type="module">
    import {
      isMarkdownTable,
      renderMarkdownTable,
    } from "https://esm.sh/render-markdown-tables@1.0.17";

    const elements = document.querySelectorAll(".md-table");
    Array.from(elements).filter(isMarkdownTable).forEach(renderMarkdownTable);
  </script>
</html>
1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago