FIX: Remove console warning for "nohighlight" (#19447)
This commit is contained in:
parent
8b496824c3
commit
f58eaf529f
|
@ -878,8 +878,8 @@ eviltrout</p>
|
|||
|
||||
assert.cooked(
|
||||
"```text\ntext\n```",
|
||||
'<pre><code class="lang-nohighlight">text\n</code></pre>',
|
||||
"handles text by adding nohighlight"
|
||||
'<pre><code class="lang-plaintext">text\n</code></pre>',
|
||||
"handles text by adding plaintext"
|
||||
);
|
||||
|
||||
assert.cooked(
|
||||
|
@ -908,7 +908,7 @@ eviltrout</p>
|
|||
|
||||
assert.cooked(
|
||||
"```eviltrout\nhello\n```",
|
||||
'<pre data-code-wrap="eviltrout"><code class="lang-nohighlight">hello\n</code></pre>',
|
||||
'<pre data-code-wrap="eviltrout"><code class="lang-plaintext">hello\n</code></pre>',
|
||||
"it converts to custom block unknown code names"
|
||||
);
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ function render(tokens, idx, options, env, slf, md) {
|
|||
md.options.discourse.acceptableCodeClasses || [];
|
||||
|
||||
if (TEXT_CODE_CLASSES.includes(tag)) {
|
||||
className = "lang-nohighlight";
|
||||
className = "lang-plaintext";
|
||||
} else if (acceptableCodeClasses.includes(tag)) {
|
||||
className = `lang-${tag}`;
|
||||
} else {
|
||||
className = "lang-nohighlight";
|
||||
className = "lang-plaintext";
|
||||
attributes["wrap"] = tag;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ export function setup(helper) {
|
|||
opts.acceptableCodeClasses = (siteSettings.highlighted_languages || "")
|
||||
.split("|")
|
||||
.filter(Boolean)
|
||||
.concat(["auto", "nohighlight"]);
|
||||
.concat(["auto", "plaintext"]);
|
||||
});
|
||||
|
||||
helper.allowList(["pre[data-code-*]"]);
|
||||
|
|
|
@ -2214,7 +2214,7 @@ en:
|
|||
display_name_on_posts: "Show a user's full name on their posts in addition to their @username."
|
||||
show_time_gap_days: "If two posts are made this many days apart, display the time gap in the topic."
|
||||
short_progress_text_threshold: "After the number of posts in a topic goes above this number, the progress bar will only show the current post number. If you change the progress bar's width, you may need to change this value."
|
||||
default_code_lang: "Default programming language syntax highlighting applied to code blocks (auto, nohighlight, ruby, python etc.). This value must also be present in the `highlighted languages` site setting."
|
||||
default_code_lang: "Default programming language syntax highlighting applied to code blocks (auto, text, ruby, python etc.). This value must also be present in the `highlighted languages` site setting."
|
||||
warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."
|
||||
autohighlight_all_code: "Force apply code highlighting to all preformatted code blocks even when they didn't explicitly specify the language."
|
||||
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many languages may impact performance) see: <a href='https://highlightjs.org/static/demo/' target='_blank'>https://highlightjs.org/static/demo</a> for a demo"
|
||||
|
|
|
@ -549,17 +549,17 @@ RSpec.describe PrettyText do
|
|||
expect(PrettyText.cook("``` ruby the mooby\n`````")).to eq('<pre><code class="lang-ruby"></code></pre>')
|
||||
expect(PrettyText.cook("```cpp\ncpp\n```")).to match_html("<pre><code class='lang-cpp'>cpp\n</code></pre>")
|
||||
expect(PrettyText.cook("```\ncpp\n```")).to match_html("<pre><code class='lang-auto'>cpp\n</code></pre>")
|
||||
expect(PrettyText.cook("```text\ncpp\n```")).to match_html("<pre><code class='lang-nohighlight'>cpp\n</code></pre>")
|
||||
expect(PrettyText.cook("```custom\ncustom content\n```")).to match_html("<pre data-code-wrap='custom'><code class='lang-nohighlight'>custom content\n</code></pre>")
|
||||
expect(PrettyText.cook("```custom foo=bar\ncustom content\n```")).to match_html("<pre data-code-foo='bar' data-code-wrap='custom'><code class='lang-nohighlight'>custom content</code></pre>")
|
||||
expect(PrettyText.cook("```INVALID a=1\n```")).to match_html("<pre data-code-a='1' data-code-wrap='INVALID'><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```INVALID a=1, foo=bar , baz=2\n```")).to match_html("<pre data-code-a='1' data-code-foo='bar' data-code-baz='2' data-code-wrap='INVALID'><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```text\n```")).to match_html("<pre><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```text\ncpp\n```")).to match_html("<pre><code class='lang-plaintext'>cpp\n</code></pre>")
|
||||
expect(PrettyText.cook("```custom\ncustom content\n```")).to match_html("<pre data-code-wrap='custom'><code class='lang-plaintext'>custom content\n</code></pre>")
|
||||
expect(PrettyText.cook("```custom foo=bar\ncustom content\n```")).to match_html("<pre data-code-foo='bar' data-code-wrap='custom'><code class='lang-plaintext'>custom content</code></pre>")
|
||||
expect(PrettyText.cook("```INVALID a=1\n```")).to match_html("<pre data-code-a='1' data-code-wrap='INVALID'><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```INVALID a=1, foo=bar , baz=2\n```")).to match_html("<pre data-code-a='1' data-code-foo='bar' data-code-baz='2' data-code-wrap='INVALID'><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```text\n```")).to match_html("<pre><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```auto\n```")).to match_html("<pre><code class='lang-auto'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```ruby startline=3 $%@#\n```")).to match_html("<pre data-code-startline='3'><code class='lang-ruby'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid a_-你=17\n```")).to match_html("<pre data-code-a_-='17' data-code-wrap='mermaid'><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid foo=<script>alert(document.cookie)</script>\n```")).to match_html("<pre data-code-foo='<script>alert(document.cookie)</script>' data-code-wrap='mermaid'><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid foo= begin admin o\n```")).to match_html("<pre data-code-wrap='mermaid'><code class='lang-nohighlight'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid a_-你=17\n```")).to match_html("<pre data-code-a_-='17' data-code-wrap='mermaid'><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid foo=<script>alert(document.cookie)</script>\n```")).to match_html("<pre data-code-foo='<script>alert(document.cookie)</script>' data-code-wrap='mermaid'><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```mermaid foo= begin admin o\n```")).to match_html("<pre data-code-wrap='mermaid'><code class='lang-plaintext'>\n</code></pre>")
|
||||
expect(PrettyText.cook("```c++\nc++\n```")).to match_html("<pre><code class='lang-c++'>c++\n</code></pre>")
|
||||
expect(PrettyText.cook("```structured-text\nstructured-text\n```")).to match_html("<pre><code class='lang-structured-text'>structured-text\n</code></pre>")
|
||||
expect(PrettyText.cook("```p21\np21\n```")).to match_html("<pre><code class='lang-p21'>p21\n</code></pre>")
|
||||
|
|
Loading…
Reference in New Issue