markdown-it 解析渲染表格语法扩展插件 (表格合并单元格)

markdown-it-table-merge-cells (表格合并单元格,不用写html)

- 以下是浏览器上预期的表格:
- Here's the table expected on browser:

 

表格单元格合并效果图


介绍一个 markdown-it 解析表格的语法扩展插件,我为了满足自己的需求写的。
有需要的looklook

  • PS:`markdown-it-multimd-table-extra`包改名为`markdown-it-table-merge-cells`
  • PS: `markdown-it-multimd-table-extra` package was renamed as `markdown-it-table-merge-cells`.
  • `markdown-it` 增强辅助类表格语法插件(目前只支持列合并和行合并。后面会考虑加入行列合并。)
  • 由于`markdown-it-multimd-table`不支持配合`prettier`格式化一起使用,可读性和可维护性就比较差,因此我自己写一个。
  • 凡是用`markdown-it`作为解析器的`markdown`编辑器,只要该编辑器支持配置即可使用此插件扩展表格语法。
  • `markdown-it` enhanced auxiliary class table syntax plug-in (Currently, only column merging and row merging are supported. Will consider joining the column merge later.)
  • Because `markdown-it-multimd-table` is not supported with `prettier` formatting, making it less readable and maintainable, so I wrote my own.
  • Any `markdown` editor that uses `markdown-it` as the parser can use this plugin to extend the table syntax as long as the editor supports configuration.

Usage 

```js
npm i markdown-it -D
npm i markdown-it-table-merge-cells -D
// 以上两行效果同下行/The above two lines have the same downward effect
npm i markdown-it  markdown-it-table-merge-cells -D


import MarkdownIt from "markdown-it";
import TableMergeCells from "markdown-it-table-merge-cells";

const md = new MarkdownIt()

md.use(TableMergeCells);

console.log(
  md.render(`
|  4col   |   ==    |  ==  |   ==    |
| :-----: | :-----: | :--: | :-----: |
|  2row   | content | 3row | content |
|   ^^    | content |  ^^  | content |
| content | content |  ^^  | content |
`)
);
```

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值