Table parsing error
liushilive opened this issue · 1 comments
liushilive commented
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>&&</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:
symbol | describe |
---|---|
! | not |
&& 、-a | and |
` |
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>&&</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:
symbol | describe |
---|---|
! | not |
&& 、-a | and |
|| 、-o | or |
frostming commented
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 |