mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
80484b76a5
Summary: 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 ``` 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): lang=text ```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``` Or, just specify that you are writing in the language "text" (Remarkup-only): lang=text ```lang=text cpp php python``` To reduce impact and help you, the logic of this strict implementation is: - must have backticks - must not have any valid remarkup option, like lang=, counterexample, etc. - must not have content in the same line of the last backticks - must have a known language in our proposed subset If everything is OK, we remove that language from the content since it would be otherwise displayed. Interestingly, this could improve performance when rendering README files or snippets from external websites, since - in case - we do not need to guess the language using our deep dark magic. Closes T15481 Test Plan: We added some nice unit tests. Ensure that this test passes: PhutilRemarkupEngineTestCase::testEngine Optionally, take vision of these, before and after: https://we.phorge.it/P16 Change the test plan slightly every time, to make sure it is not in your cache. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15481 Differential Revision: https://we.phorge.it/D25299 |
||
---|---|---|
.. | ||
__tests__ | ||
aphront | ||
applications | ||
docs | ||
extensions | ||
infrastructure | ||
view | ||
__phutil_library_init__.php | ||
__phutil_library_map__.php |