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

Code block incorrectly parsed in commonmarker 1.0.0.pre #202

Closed
andreas12345 opened this issue Nov 20, 2022 · 2 comments · Fixed by #203
Closed

Code block incorrectly parsed in commonmarker 1.0.0.pre #202

andreas12345 opened this issue Nov 20, 2022 · 2 comments · Fixed by #203
Assignees

Comments

@andreas12345
Copy link

Hi,

I noticed that code blocks are sometimes not parsed correctly in commonmarker (1.0.0.pre arm64-darwin):

irb(main):011:0> s = "\n```\n\nx\n\n```\n"
=> "\n```\n\nx\n\n```\n"
irb(main):012:0> print(s)

```                                                           
                                                              
x                                                             
                                                              
```                                                           
=> nil                                                        
irb(main):013:0> Commonmarker.to_html(s)
=> "<p>x</p>\n<pre><code></code></pre>\n"

The "x" is not inside the generated code & pre tags.

Here is what Comrak CLI 0.15.0 returns for the same piece of Markdown code:

<pre style="background-color:#2b303b;"><code>
<span style="color:#c0c5ce;">                                                              
</span><span style="color:#c0c5ce;">x                                                             
</span><span style="color:#c0c5ce;">                                                              
</span>
</code></pre>

Thanks,
Andreas

@kivikakk
Copy link
Collaborator

Thanks for the report. It looks like the default front-matter delimiter is "", rather than unspecified, meaning the first line is getting eaten as frontmatter. The comrak execution that produces similar output is:

$ printf "\n```\n\nx\n\n```\n" | comrak --front-matter-delimiter ''
<p>x</p>
<pre style="background-color:#2b303b;"><code>

</code></pre>

@gjtorikian
Copy link
Owner

Thanks for reporting this! I was able to also tighten up the string parsing in general. 1.0.0.pre.2 will be released soon.

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

Successfully merging a pull request may close this issue.

3 participants