-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add support for tildes in attributes of fenced code block #127
Conversation
Running the tests pulls in changes unrelated to this change, I think perhaps because the VS Code theme has changed the colours? I've run the tests against main, and included that as a separate PR if that is preferred: |
build.js
Outdated
@@ -85,7 +85,7 @@ const fencedCodeBlockDefinition = (name, identifiers, sourceScope, language, add | |||
|
|||
return `fenced_code_block_${name}: | |||
begin: | |||
(^|\\G)(\\s*)(\`{3,}|~{3,})\\s*(?i:(${identifiers.join('|')})((\\s+|:|,|\\{|\\?)[^\`~]*)?$) | |||
(^|\\G)(\\s*)(\`{3,}|~{3,})\\s*(?i:(${identifiers.join('|')})((\\s+|:|,|\\{|\\?)(?:(?!\`{3}|~{3}).)*)?$) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to align this with the markdown spec: https://spec.commonmark.org/0.30/#fenced-code-blocks Here's the relevant section:
If the info string comes after a backtick fence, it may not contain any backtick characters. (The reason for this restriction is that otherwise some inline code would be incorrectly interpreted as the beginning of a fenced code block.)
Github doesn't do the same for fetched code blocks starting with ~
. As far as I can tell, the info string in those can contain as many ~
as you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the difficulty with Markdown is that there are so many different flavours, Commonmark is just one spec.
What would you recommend doing here? Since common mark only references backticks, we could potentially, be more or less strict.
What do you reckon to doing [^\`]*
which would allow as many tildes as desired whilst keeping the restriction on backticks?
This would cause issues with ~~~foo~~~
but I can't find anything that supports using tildes like that.
Thanks! |
This fixes #126.
Fenced code blocks fail if there is a tilde (or backtick) in the attributes of a fenced codeblock.
For example, the following markdown highlights as expected.
But as soon as you add a tilde to the filepath, syntax highlighting stops working: