frostming / marko

A markdown parser with high extensibility.

Home Page:https://marko-py.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table parsing error

liushilive opened this issue · comments

code:

from marko.ext.gfm import gfm

gfm("""symbol | describe
:---:|---
`!`  | not
`&&`、`-a` | and
`||`、`-o` | or
""")

Actual Out:

<table>\n<thead>\n<tr>\n<th align="center">symbol</th>\n<th>describe</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align="center"><code>!</code></td>\n<td>not</td>\n</tr>\n<tr>\n<td align="center"><code>&amp;&amp;</code><code>-a</code></td>\n<td>and</td>\n</tr>\n<tr>\n<td align="center">`</td>\n<td></td>\n</tr>\n</tbody></table>

Actual Priview:

symboldescribe
!not
&&-aand
`

Desired Out:

<table>\n<thead>\n<tr>\n<th align="center">symbol</th>\n<th>describe</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align="center"><code>!</code></td>\n<td>not</td>\n</tr>\n<tr>\n<td align="center"><code>&amp;&amp;</code><code>-a</code></td>\n<td>and</td>\n</tr>\n<tr>\n<td align="center"><code>||</code><code>-o</code></td>\n<td>or</td>\n</tr>\n</tbody></table>

Desired Priview:

symboldescribe
!not
&&-aand
||-oor

This is not a bug, block elements are always parsed before inline elements, so | inside the `` backticks are recognized as the cell delimiter. You can paste the markdown code to the comment box(where GFM is used, officially) to see the preview.

To get the desired output, you need to escape that | as specified at https://github.github.com/gfm/#example-200

symbol | describe
:---:|---
`!`  | not
`&&``-a` | and
`\|\|``-o` | or

Which will be renderered as:

symbol describe
! not
&&-a and
||-o or