MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

Allow newlines for role syntax parsing

Open matthew-brett opened this issue 5 years ago • 4 comments

I noticed that when my {download} inline markup flows across lines, the parsing fails. For example:

from myst_parser.main import to_html

markdown = """
{download}`Link text <test_long_link.py>`.

Here the link runs across lines, breaking parsing {download}`Here is a short
piece of link text <test_long_link.py>`.
"""

print(to_html(markdown))

generates

p><code class="sphinx-role">{download}[Link text &lt;test_long_link.py&gt;]</code>.</p>
<p>Here the link runs across lines, breaking parsing {download}<code>Here is a short piece of link text &lt;test_long_link.py&gt;</code>.</p>

Is this expected? It does not seem to be the case for Sphinx / ReST parsing.

matthew-brett avatar Nov 11 '20 12:11 matthew-brett

the way how roles are currently indentified in https://github.com/executablebooks/mdit-py-plugins/blob/5c0038fd4348cc37548b3ee7891a9f380517f959/mdit_py_plugins/myst_role/index.py#L8, it is expected.

but this could be relatively easily changed to allow for new line breaks

chrisjsewell avatar Jan 05 '21 17:01 chrisjsewell

In the meantime we should document that roles cannot span multiple lines as well (unless you think this enhancement will be done easily/quickly? wdyt?)

choldgraf avatar Jan 05 '21 17:01 choldgraf

It's pretty easy to run over a line in a role, by accident, so my vote would be to change the behavior. Are there other Markdown inline markups that cannot run over lines?

matthew-brett avatar Jan 05 '21 19:01 matthew-brett

we have come across this bug a couple times in some of our projects during migration checks. @AakashGfude perhaps we can see if this regex can be updated to accept newlines for roles.

mmcky avatar Feb 16 '21 04:02 mmcky