We add support to code blocks with the language expressed as GitLab/GitHub/StackOverflow/...
"flavored markdown". Example:
So we support this syntax: (to avoid confusion see it online on the Diff)
lang=text
(three backticks)php```php
$asd = 1;
(three backticks)```
Before this change, this was the only supposed syntax in Remarkup, with an explicit "lang=":
(three backticks)lang=text
```lang=php
$asd = 1;
(three backticks)```
There iThis change introduces a minor riskk to eat legitimate Remarkup content, since Remarkup allows
to do a multi-line in this way:
(three backticks)$asd = 1;lang=text
$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```$asd = 1;
the language is really a language.
- in case, we remove that language from the content since it would be otherwise displayed $asd = 2;```
This should improve performance when rendering README files or snippets from external websites,The above example still works, but, there is a chance that hardcore Remarkup people
since at the moment the language was currently being guessed using deep dark magichave a problem when doing a code block to mention programming languages.
There is a chance that hardcore Remarkup people have a problem when doing a code block
to mention programming languages. Like mentioning cppIn short, php and python inthis can be problematic since "cpp" will be eaten from this way:list:
(three backticks)cppCOUNTEREXAMPLE
```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 encountering a similar problem:
If you are affected, please just add at least one newline after the first backticks:Just *add* a newline on the top to reach a valid raw Markdown list:
(three backticks)lang=text
```
cpp
php
python(three backticks)
```
And/orOr, use an explicitjust *remove* a newline from the bottom to reach a valid raw Remarkup option:list:
(three backticks)lang=text
```cpp
php
python(three backticks)```
Even better - you can also create whatever code block adopting the way in markdown,
recognized by one billion platformsTo reduce any risk, that is also a completely valid Remarkup:the logic of this strict implementation is:
(three- capture the thing expressed just after the first backticks (language candidate)
cpp- capture the alien thing expressed before the last backticks (garbage)
- if the language was not declared as lang=something, do a semantic check to verify that
phpthe language is really a language.
python- 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,
(three backticks)since at the moment the language was currently being guessed using deep dark magic.
Doing this is not socially very nice because it is not usable in GitLab, GitHub and Stack Overflow.
Closes T15481