We add support to code blocks with the language expressed as GitLab/GitHub/StackOverflow/...
"flavored markdown".
So we support this syntax: (to avoid confusion see it online on the Diff)
lang=text
```php
$asd = 1;
```
Before this change, this was the only supposed syntax in Remarkup, with an explicit "lang=":
lang=text
```lang=php
$asd = 1;
```
This change introduces a minor risk to eat legitimate Remarkup content, since Remarkup allows
to do a multi-line in this way:
lang=text
```$asd = 1;
$asd = 2;```
The above example still works, but, there is a chance that hardcore Remarkup people
have a problem when doing a code block to mention programming languages.
In short, this can be problematic since "cpp" will be eaten from this list:
COUNTEREXAMPLE
```cpp
php
python
```
If you are encountering a similar problem:Using the above example is not socially nice because it is not usable in GitLab, GitHub and Stack Overflow.
If your first line is eaten:
Just *add* a newline on the top to reach a valid raw Markdown list (suggested, valid in Remarkup + Markdown):
lang=text
```
cpp
php
python
```
Or, just add "text" to specify that as language (suggested, valid in Remarkup + Markdown):
```text
cpp
php
python
```
Or, just *remove* a newline from the bottom to reach a valid raw Remarkup list (Remarkup-only):
lang=text
```cpp
php
python```
To reduce any riskOr, the logic of this strict implementation is:just specify that you are writing in the language "text" (Remarkup-only):
- capture the thing expressed just after the first backticks ( language candidate)=text
- 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 tha ```lang=text
the language is really a language. cpp
- in case php
python```
To reduce impact and help you, we remove that language from the content since it would be otherwise displayedthe logic of this strict implementation is:
This should improve performance when rendering README files or snippets from external websites,- must have backticks, must have any known remarkup option like lang=
since at the moment the language was currently being guessed using deep dark magic.- must be a known language
- must be not content in the same line of the last backticks
- in case, we remove that language from the content since it would be otherwise displayed
Doing this is not socially very nice because it is not usable in GitLab, GitHub and Stack OverflowThis could improve performance when rendering README files or snippets from external websites,
since at the moment the language was guessed using deep dark magic.
Closes T15481