showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.19k stars 1.56k forks source link

Markdown tables only get wrapped in a p-tag instead of a proper html table #945

Closed MielkeDaniel closed 2 years ago

MielkeDaniel commented 2 years ago

First time working with markdown and html converters. Iยดm trying to convert this table:

| Type | File   | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex. Score | Capabilities |
|========|=================|============|=======|=======|===============|==============|  
| ๐Ÿ“ | ./uploads/contracts/name.sol | 1 | **** | 564 | 535 | 308 | 152 | 221 | **<abbr title='Uses Assembly'>๐Ÿ–ฅ</abbr><abbr title='Payable Functions'>๐Ÿ’ฐ</abbr><abbr title='Uses Hash-Functions'>๐Ÿงฎ</abbr><abbr title='create/create2'>๐ŸŒ€</abbr>** |
| ๐Ÿ“ | ./uploads/contracts/ERC2981.sol | 1 | **** | 48 | 37 | 24 | 7 | 15 | **** |
| ๐Ÿ” | ./uploads/contracts/IERC2981.sol | **** | 1 | 18 | 14 | 3 | 10 | 3 | **** |
| ๐Ÿ“ | ./uploads/contracts/MockERC721.sol | 1 | **** | 27 | 27 | 19 | 1 | 18 | **** |
| ๐Ÿ“ | ./uploads/contracts/MutantBatz.sol | 1 | **** | 285 | 262 | 157 | 46 | 159 | **<abbr title='Uses Assembly'>๐Ÿ–ฅ</abbr><abbr title='Uses Hash-Functions'>๐Ÿงฎ</abbr>** |
| ๐Ÿ“ | ./uploads/contracts/Originals.sol | 1 | **** | 142 | 128 | 83 | 22 | 81 | **<abbr title='Uses Hash-Functions'>๐Ÿงฎ</abbr>** |
| ๐Ÿ“ | ./uploads/contracts/SutterTreasury.sol | 1 | **** | 23 | 23 | 17 | 1 | 20 | **<abbr title='Payable Functions'>๐Ÿ’ฐ</abbr>** |
| ๐Ÿ“๐Ÿ” | **Totals** | **6** | **1** | **1107**  | **1026** | **611** | **239** | **517** | **<abbr title='Uses Assembly'>๐Ÿ–ฅ</abbr><abbr title='Payable Functions'>๐Ÿ’ฐ</abbr><abbr title='Uses Hash-Functions'>๐Ÿงฎ</abbr><abbr title='create/create2'>๐ŸŒ€</abbr>** |

into html, which works perfectly fine in the showdown live editor in the browser, but not when trying to parse it in node using

const html = converter.makeHtml(`Header 1 | Header 2
  -------- | --------
  Cell 1   | Cell 2
  Cell 3   | Cell 4`);

for example. It ends up looking like this:

<p>Header 1 | Header 2
  -------- | --------
  Cell 1   | Cell 2
  Cell 3   | Cell 4</p>

for example. Any idea what could be wrong there?

MielkeDaniel commented 2 years ago

Ooooh, I looked through the options but somehow didnยดt see the table options part. In case someone else faces this issues you need to specify table suport when creating the converter like so: const converter = new showdown.Converter({ tables: "true" });