In short this changWe adds support to code blocks expressed as "GFM"."Flavored Markdown"
that is the syntax in use by GitLab, Example:GitHub and Stack Overflow at least.
(three backticks)php
$asd = 1;
(three backticks)
Note that, before this change, this was the only supposed syntax in Remarkup:
(three backticks)lang=php
$asd = 1;
(three backticks)
But note that we were alloging also this:
(three backticks)$asd = 1;
$asd = 2;(three backticks)
The logic of this implementation is:
- quickly capture whatever alien thing was expressed just after the first backtickscapture whatever thing expressed just after the first backticks (language candidate)
- capture whatever alien thing expressed before the last backticks (garbage)
- if the language was not declared as lang=something, do a semantic check to verify that
the language is really a language.
- in case, we remove that language from the content since it would be otherwise displayed
This should improve performance when rendering README files or snippets from external websites,
since at the moment the language was currently being guessed using deep dark magic.
There is a chance that hardcore Remarkup people have a problem when doing a code block
to mention programming languages. Like mentioning cpp, php and python in this way:
(three backticks)cpp
php
python(three backticks)
Doing this is not socially very nice because it is not usable in GitLab, GitHub and Stack Overflow.
If you are affected, please just add at least one newline after the first backticks:
(three backticks)
cpp
- if the language was not declared, check that capture with a stricter regex, to capture "php", "c++", etc. php
- eventually use that python(three backticks)
And/or, removing that line from the content (since it would be otherwise displayed)use an explicit Remarkup option:
This should improve performance when rendering README files from GitHub, since at the moment (three backticks)lang=text
cpp
the language was currently being guessed using deep dark magic. php
python(three backticks)
Note that this is done before re-indenting the codeOr - even better - you can just create whatever code block adopting the canonical
flavored markdown, recognized by one billion platforms, so we avoid re-indenting that parameter wasting CPU.that is also a valid Remarkup:
After this change, we simply render better README files coming from GitHub (three backticks)
and also from its nicest friend, GitLab. cpp
php
python
(three backticks)
Closes T15481