-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown parsing bug: inline code in list item #6284
Comments
Indeed,
|
The cause is pretty clear: -- parses inline code, between n `s and n `s
code :: PandocMonad m => MarkdownParser m (F Inlines)
code = try $ do
starts <- many1 (char '`')
skipSpaces
result <- (trim . T.concat) <$>
manyTill (notFollowedBy (inList >> listStart) >>
(many1Char (noneOf "`\n") <|> many1Char (char '`') <|>
(char '\n' >> notFollowedBy' blankline >> return " "))) (try (skipSpaces >> count (length starts) (char '`') >>
notFollowedBy (char '`'))) I think the
which pandoc's markdown doesn't want to treat as a nested list. commonmark makes a saner decision and lets block structure trump inline structure here, so we get a nested list. See commit 9c4ba81 and #5627. I'm tempted to revert this part of the change; in general, I'd prefer to move towards convergence with commonmark on this kind of thing. But we can see if @leungbk has any comments. |
@jgm, not entirely sure I understand. 1. hi `there
1. ok` works along the lines of what I would expect, treating the second line as a lazy continuation of the first line: <ol type="1">
<li>hi <code>there 1. ok</code></li>
</ol> Adding a newline also works more or less as I would expect, evidently choosing the block structure over inline code: 1. hi `there
1. ok` produces <ol type="1">
<li><p>hi `there</p>
<ol type="1">
<li>ok`</li>
</ol></li>
</ol> These two cases seemingly should be handled by This, however, doesn't do what I would expect: 1. hi `1. there ok` produces <ol type="1">
<li>hi `1. there ok`</li>
</ol> Which is seemingly the effect of As far as I can tell, the reason for 1. hi `x
2. ok` But it also (incorrectly) catches cases like 1. hi `x``2. ok` which produces <ol type="1">
<li>hi `x```2. ok`</li>
</ol> instead of what I would expect (and what commonmark does), i.e. <ol>
<li>hi <code>x```2. ok</code></li>
</ol> and the case in the OP. P.S. From what I can gather (and I might be mistaken!) the fix for the immediate issue and the related case with backticks described above would be to move P.P.S. After looking through the code and testing my suspicions, apparently there's also an issue of 1. `- x`
2. `* x`
3. `+ x` not being parsed as inline code, because |
Oh yes, I guess you're right, it's for cases like
The small change you recommend sounds good to me for now, even though I'd be more tempted simply to remove the check, which would align more with commonmark behavior. |
Closes #6284. Previously inline code containing list markers was sometimes parsed incorrectly.
Seems like this is as of yet unreported, sorry for the noise if it is. Anywho, given the following Markdown:
Pandoc produces:
This is unexpected, I would expect something along the lines of
Parser seems to be confused specifically by the
(1)
part, without it, it works as expected. Also works as expected outside of list items.Also breaks in the same way with things like
Seems like a precedence conflict between inline code and list markers?
The text was updated successfully, but these errors were encountered: