remark-grid-tables
This plugin parses custom Markdown syntax to describe tables. It was inspired by [this syntax](https://github.com/smartboyathome/Markdown-GridTables/blob/b4d16d5d254bed4336713d27eb8a37dc0e5f4273/mdx_grid_tables.py).
Last updated 4 months ago by talone .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install remark-grid-tables 
SYNC missed versions from official npm registry.

remark-grid-tables Build Status Coverage Status

This plugin parses custom Markdown syntax to describe tables. It was inspired by this syntax.

AST nodes

It adds a new node type to the mdast produced by remark: gridTable.

If you are using rehype, the stringified HTML result will be a table.

It is up to you to have CSS rules producing the desired result for these table.

interface GridTable <: Parent {
  type: "gridTable";
  data: {
    hName: "table";
  }
}

A gridTable mdast node can contain the following mdast node types:

tableHeader

interface TableHeader <: Parent {
  type: "tableHeader";
  data: {
    hName: "thead" or "tbody";
  }
}

Where hName can be either thead or tbody.

tableRow

interface TableRow <: Parent {
  type: "tableRow";
  data: {
    hName: "tr";
  }
}

tableCell

interface TableCell <: Parent {
  type: "tableCell";
  data: {
    hName: "td";
    hProperties: {
      colspan: number >= 1;
      rowspan: number >= 1;
    }
  }
}

Syntax

For example:

# Grid table

## Basic example

+-------+----------+------+
| Table Headings   | Here |
+-------+----------+------+
| Sub   | Headings | Too  |
+=======+==========+======+
| cell  | column spanning |
+ spans +----------+------+
| rows  | normal   | cell |
+-------+----------+------+
| multi | cells can be    |
| line  | *formatted*     |
|       | **paragraphs**  |
| cells |                 |
| too   |                 |
+-------+-----------------+

produces:

<h1>Grid table</h1>
<h2>Basic example</h2>

<table>
  <thead>
    <tr>
      <th colspan="2" rowspan="1"><p>Table Headings</p></th>
      <th colspan="1" rowspan="1"><p>Here</p></th>
    </tr>
    <tr>
      <th colspan="1" rowspan="1"><p>Sub</p></th>
      <th colspan="1" rowspan="1"><p>Headings</p></th>
      <th colspan="1" rowspan="1"><p>Too</p></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td colspan="1" rowspan="2"><p>cell
spans
rows</p></td>
      <td colspan="2" rowspan="1"><p>column spanning</p></td>
    </tr>
    <tr>
      <td colspan="1" rowspan="1"><p>normal</p></td>
      <td colspan="1" rowspan="1"><p>cell</p></td>
    </tr>
    <tr>
      <td colspan="1" rowspan="1"><p>multi
line</p><p>cells
too</p></td>
      <td colspan="2" rowspan="1"><p>cells can be
<em>formatted</em>
<strong>paragraphs</strong></p></td>
    </tr>
  </tbody>
</table>

Note: the top of a cell must be indicated by +- followed by some - or + and finished by -+.
So, this is not a correct cell:

+--+
|a |
+--+

But, this is a correct cell:

+---+
| a |
+---+

Installation

npm:

npm install remark-grid-tables

Usage

Dependencies:

const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

const remarkGridTables = require('remark-grid-tables')

Usage:

unified()
  .use(remarkParse)
  .use(remarkGridTables)
  .use(remark2rehype)
  .use(stringify)

License

MIT © Zeste de Savoir

Current Tags

  • 2.1.1                                ...           latest (4 months ago)

40 Versions

  • 2.1.1                                ...           4 months ago
  • 2.1.0                                ...           5 months ago
  • 2.0.2                                ...           6 months ago
  • 1.7.1                                ...           10 months ago
  • 1.7.0                                ...           a year ago
  • 1.6.1                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.16                                ...           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.11                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 0.0.13                                ...           3 years ago
  • 0.0.12                                ...           3 years ago
  • 0.0.11                                ...           3 years ago
  • 0.0.10                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 41
This Month 41
Last Day 0
Last Week 0
Last Month 2
Dependencies (4)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |