Skip to content

| in backticks breaks Table Syntax  #549

@mDuo13

Description

@mDuo13

GitHub-Flavored Markdown, PHP Markdown Extra, and the Python Markdown Extra extension all support table syntax, which depends on the bar character (|) to delineate columns. However, only Python's parser does not nicely handle bar characters in code font (backticks) even within tables. It splits a column on any bar character, even if it's part of a code-font sequence. (This causes it to drop the code syntax and any content from extraneous columns, as well.)

A better behavior would be to match the GFM and PHP Markdown Extra behavior, which doesn't split tables on bars that are inside backticks (code-font block).

| Title | Row |
|---|---|
| `a1|a2` | b |

GitHub rendering (PHP Markdown Extra does the same):

Title Row
`a1 a2`

Python's rendering looks a little more like this:

Title Row
`a1 a2`

Actual output from the interpreter:

>>> s2 = """
... | Title | Row |
... |---|---|
... | `a1|a2` | b |
... 
... """
>>> 
>>> markdown.markdown(s2, ['markdown.extensions.extra'])
'<table>\n<thead>\n<tr>\n<th>Title</th>\n<th>Row</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>`a1</td>\n<td>a2`</td>\n</tr>\n</tbody>\n</table>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions