Skip to content
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 parser doesn't recognize CodeBlock inside QuotedBlock #342

Closed
ljw1004 opened this issue Oct 1, 2015 · 6 comments
Closed

Markdown parser doesn't recognize CodeBlock inside QuotedBlock #342

ljw1004 opened this issue Oct 1, 2015 · 6 comments

Comments

@ljw1004
Copy link

ljw1004 commented Oct 1, 2015

Look at this piece of markdown, and how it renders, and then how it parses in FSharp.Markdown:

> __Annotation__
> This is an annnotation
> ```vb
> Module Module1
> End Module
> ```
> More annotation

Annotation
This is an annnotation

Module Module1
End Module

More annotation


But FSharp.Markdown parses the quoted block like this:

  • QuotedBlock
  • Paragraph
    - Strong
    • Literal "Annotation"
      - Literal "This is an annotation”
      - InlineCode "`vb\nModule Module1\nEnd Module"
  • Literal "More annotation"

It should parse it as a CodeBlock, but it's actually parsing it as an InlineCode.

@ljw1004
Copy link
Author

ljw1004 commented Oct 1, 2015

It's even worse that that! If the QuotedBlock contains any InlineCode after the CodeBlock, then it parses wrong -- e.g.

> Hello
> ```vb
> Module1
> ```
> That was an `inline` code block

Here it renders That was an as an inline code block, and inline as regular text.

@ljw1004
Copy link
Author

ljw1004 commented Oct 1, 2015

It also fails to parse an indented code block inside a quoted block, for example

> Hello
>     Module Module1
>     End Module
> World

What I expect here is a CodeBlock inside the QuotedBlock. But instead it rolls the indented code block just into the same single Literal that contains the rest of the stuff.

@matthid
Copy link
Member

matthid commented Oct 1, 2015

Any PR which brings us closer to the spec (http://spec.commonmark.org/0.22/) is very welcome. Adding unit tests is a big plus :)

@tpetricek
Copy link
Member

I think that our handling of indented code blocks is correct. You are always required to have a blank line around the code. The CommonMark demo requires this too: here is a live demo.

However, we are not handling the fenced code blocks correctly. We require newlines there too. The following works:

> Hello
>
> ```vb
> Module1
> ```
>
> That was an `inline` code block

... and CommonMark does not require the newlines. So, if we can fix that, that would be nice. In the meantime, adding a newline should be a reasonable workaround...

tpetricek added a commit that referenced this issue Oct 2, 2015
Do not require newline before fenced code block (fix #342)
@tpetricek
Copy link
Member

I just merged a fix for this. @matthid should I do a release so that @ljw1004 does not have to add newlines :-) or do you have some other things planned?

@matthid
Copy link
Member

matthid commented Oct 2, 2015

I'm a big fan of fast releases and my PR will take a while to become green :)
One note though: I disabled the update of the releases branch (with the binaries) so if you still need it you should enable it before doing the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants