项目作者: hennessyevan

项目描述 :
Adds Remark Grid Tables support to Gatsby
高级语言: JavaScript
项目地址: git://github.com/hennessyevan/gatsby-remark-grid-tables.git
创建时间: 2018-12-03T21:55:21Z
项目社区:https://github.com/hennessyevan/gatsby-remark-grid-tables

开源协议:

下载


gatsby-remark-grid-tables Build Status Coverage Status

This plugin parses custom Markdown syntax to describe tables. It just includes this package in the gatsby-remark chain

It’s useful for extending markdown tables to include things like rowspan, colspan etc.

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

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

  • tableHeader
  • tableRow
  • tableCell

The stringified HTML result will be a table.

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

Syntax

For example:

  1. # Grid table
  2. ## Basic example
  3. +-------+----------+------+
  4. | Table Headings | Here |
  5. +-------+----------+------+
  6. | Sub | Headings | Too |
  7. +=======+==========+======+
  8. | cell | column spanning |
  9. + spans +----------+------+
  10. | rows | normal | cell |
  11. +-------+----------+------+
  12. | multi | cells can be |
  13. | line | *formatted* |
  14. | | **paragraphs** |
  15. | cells | |
  16. | too | |
  17. +-------+-----------------+

produces:

  1. <h1>Grid table</h1>
  2. <h2>Basic example</h2>
  3. <table>
  4. <thead>
  5. <tr>
  6. <th colspan="2" rowspan="1"><p>Table Headings</p></th>
  7. <th colspan="1" rowspan="1"><p>Here</p></th>
  8. </tr>
  9. <tr>
  10. <th colspan="1" rowspan="1"><p>Sub</p></th>
  11. <th colspan="1" rowspan="1"><p>Headings</p></th>
  12. <th colspan="1" rowspan="1"><p>Too</p></th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <td colspan="1" rowspan="2"><p>cell
  18. spans
  19. rows</p></td>
  20. <td colspan="2" rowspan="1"><p>column spanning</p></td>
  21. </tr>
  22. <tr>
  23. <td colspan="1" rowspan="1"><p>normal</p></td>
  24. <td colspan="1" rowspan="1"><p>cell</p></td>
  25. </tr>
  26. <tr>
  27. <td colspan="1" rowspan="1"><p>multi
  28. line</p><p>cells
  29. too</p></td>
  30. <td colspan="2" rowspan="1"><p>cells can be
  31. <em>formatted</em>
  32. <strong>paragraphs</strong></p></td>
  33. </tr>
  34. </tbody>
  35. </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:

  1. +--+
  2. |a |
  3. +--+

But, this is a correct cell:

  1. +---+
  2. | a |
  3. +---+

Installation

npm:

  1. npm install remark-grid-tables

License

MIT © Zeste de Savoir