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

Fix fenced code blocks in Markdown lexer #1442

Merged
merged 2 commits into from Feb 19, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Feb 18, 2020

Many flavours of Markdown permit fenced code blocks. These blocks may begin with three or more ` or ~. The current implementation only permits three. This PR fixes that.

The PR also fixes a bug in code blocks that would match the closing fence even if it occurred within code in the block.

It fixes #1439.

@pyrmont pyrmont self-assigned this Feb 18, 2020
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Feb 18, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Feb 18, 2020

@Ravlen If you could have a look over this, that'd be great!

@Ravlen
Copy link
Contributor

Ravlen commented Feb 19, 2020

@pyrmont I'm not a developer (I'm a technical writer with GitLab, though I noticed I really should have updated my profile -> done) and am not sure how to test this locally, but the regex certainly seems to make sense. Instead of triple backtick/tilde fences, it's 3 or more, and then match the capturing group for the closing fence. Perfectly logical.

Could you double check that this doesn't break when nesting codeblocks (the primary reason for quad fences)? So, a real use case I might have, in our style guide explaining how to use code blocks:

Use a colon to introduce codeblock examples, and use triple backtick fences with
a language tag to make sure the Rouge code coloring will apply:

````markdown
Here is an example of [feature](../feature.md):

```console
$ echo "Sample feature output"
```
````

If this example works too, then I'm 100% thrilled to see the fix! 🙇 🎉 We use Rouge for both GitLab and our docs site, so it will be a big help. I run into edge cases from time to time, and I'll see if I can at least suggest improved Regex next time, if I can figure it out. 👍

@jneen
Copy link
Member

jneen commented Feb 19, 2020

+1 from me, looks good on the implementation as well.

@pyrmont pyrmont merged commit 65207be into rouge-ruby:master Feb 19, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Feb 19, 2020

Thanks all! I've merged it in and this will be part of the v3.17.0 release. That's scheduled to be pushed out on Tuesday 10 March.

@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Feb 19, 2020
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 this pull request may close these issues.

Bug/Request: quad-backtick code blocks in markdown lexer
3 participants