We add support to code blocks with the language expressed as "Flavored Markdown"GitLab/GitHub/StackOverflow/...
that is the syntax in use by GitLab,"flavored markdown". GitHub and Stack Overflow at least.Example:
(three backticks)php
$asd = 1;
(three backticks)
Before this change, this was the only supposed syntax in Remarkup:
(three backticks)lang=php
$asd = 1;
(three backticks)
There is a minor risk since Remarkup allows to do a multi-line in this way:
(three backticks)$asd = 1;
$asd = 2;(three backticks)
The logic of this strict implementation is:
- capture 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
php
python(three backticks)
And/or, use an explicit Remarkup option:
(three backticks)lang=text
cpp
php
python(three backticks)
Or - evenEven better - you can justalso create whatever code block adopting the canonicalway in markdown,
flavored markdown, recognized by one billion platforms, that is also a completely valid Remarkup:
(three backticks)
cpp
php
python
(three backticks)
Closes T15481