bugdown: Add 'none' as alias for no syntax highlighting in codeblocks.

This is a precursor to #14404.
This commit is contained in:
Rohitt Vashishtha 2020-03-31 05:42:15 +05:30 committed by Tim Abbott
parent 326b0e0378
commit 3f6541b306
3 changed files with 18 additions and 0 deletions

View File

@ -31,6 +31,7 @@
"matlab": 33, "matlab": 33,
"mql": 9, "mql": 9,
"mql4": 9, "mql4": 9,
"none": 1,
"objective-c": 35, "objective-c": 35,
"objectivec": 35, "objectivec": 35,
"objectpascal": 42, "objectpascal": 42,
@ -38,6 +39,7 @@
"perl": 40, "perl": 40,
"php": 44, "php": 44,
"pl": 40, "pl": 40,
"plain": 1,
"prolog": 16, "prolog": 16,
"python": 46, "python": 46,
"quote": 50, "quote": 50,
@ -45,6 +47,7 @@
"rb": 39, "rb": 39,
"ruby": 39, "ruby": 39,
"rust": 8, "rust": 8,
"text": 1,
"sas": 30, "sas": 30,
"scala": 21, "scala": 21,
"scheme": 14, "scheme": 14,

View File

@ -165,6 +165,11 @@ def generic_handler(processor: Any, output: MutableSequence[str],
else: else:
return CodeHandler(processor, output, fence, lang, run_content_validators) return CodeHandler(processor, output, fence, lang, run_content_validators)
def remap_language(lang: str) -> str:
if lang in ['none', 'noop', 'text', 'plain']:
return ''
return lang
def check_for_new_fence(processor: Any, output: MutableSequence[str], line: str, def check_for_new_fence(processor: Any, output: MutableSequence[str], line: str,
run_content_validators: Optional[bool]=False) -> None: run_content_validators: Optional[bool]=False) -> None:
m = FENCE_RE.match(line) m = FENCE_RE.match(line)
@ -172,6 +177,8 @@ def check_for_new_fence(processor: Any, output: MutableSequence[str], line: str,
fence = m.group('fence') fence = m.group('fence')
lang = m.group('lang') lang = m.group('lang')
lang = remap_language(lang)
handler = generic_handler(processor, output, fence, lang, run_content_validators) handler = generic_handler(processor, output, fence, lang, run_content_validators)
processor.push(handler) processor.push(handler)
else: else:

View File

@ -119,6 +119,10 @@ class FencedBlockPreprocessorTest(TestCase):
'```c#', '```c#',
'weirdchar()', 'weirdchar()',
'```', '```',
'',
'``` none',
'no-highlight()',
'```',
'' ''
] ]
expected = [ expected = [
@ -133,6 +137,10 @@ class FencedBlockPreprocessorTest(TestCase):
'', '',
'**c#:weirdchar()**', '**c#:weirdchar()**',
'', '',
'',
'',
'**:no-highlight()**',
'',
'' ''
] ]
lines = processor.run(markdown) lines = processor.run(markdown)