From f58eaf529ffeba13a195ee8df1b03e43e2934598 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Tue, 13 Dec 2022 13:43:31 -0500 Subject: [PATCH] FIX: Remove console warning for "nohighlight" (#19447) --- .../tests/unit/lib/pretty-text-test.js | 6 +++--- .../engines/discourse-markdown/code.js | 6 +++--- config/locales/server.en.yml | 2 +- spec/lib/pretty_text_spec.rb | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js b/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js index 4e7e8247223..8e6c8887e97 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js @@ -878,8 +878,8 @@ eviltrout

assert.cooked( "```text\ntext\n```", - '
text\n
', - "handles text by adding nohighlight" + '
text\n
', + "handles text by adding plaintext" ); assert.cooked( @@ -908,7 +908,7 @@ eviltrout

assert.cooked( "```eviltrout\nhello\n```", - '
hello\n
', + '
hello\n
', "it converts to custom block unknown code names" ); diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js index 8eab865dbdb..fa935ea7682 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/code.js @@ -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-*]"]); diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index a1f73675f27..e2d44a4e963 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -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: https://highlightjs.org/static/demo for a demo" diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rb index b953ce1353e..4ffc050c90a 100644 --- a/spec/lib/pretty_text_spec.rb +++ b/spec/lib/pretty_text_spec.rb @@ -549,17 +549,17 @@ RSpec.describe PrettyText do expect(PrettyText.cook("``` ruby the mooby\n`````")).to eq('
') expect(PrettyText.cook("```cpp\ncpp\n```")).to match_html("
cpp\n
") expect(PrettyText.cook("```\ncpp\n```")).to match_html("
cpp\n
") - expect(PrettyText.cook("```text\ncpp\n```")).to match_html("
cpp\n
") - expect(PrettyText.cook("```custom\ncustom content\n```")).to match_html("
custom content\n
") - expect(PrettyText.cook("```custom foo=bar\ncustom content\n```")).to match_html("
custom content
") - expect(PrettyText.cook("```INVALID a=1\n```")).to match_html("
\n
") - expect(PrettyText.cook("```INVALID a=1, foo=bar , baz=2\n```")).to match_html("
\n
") - expect(PrettyText.cook("```text\n```")).to match_html("
\n
") + expect(PrettyText.cook("```text\ncpp\n```")).to match_html("
cpp\n
") + expect(PrettyText.cook("```custom\ncustom content\n```")).to match_html("
custom content\n
") + expect(PrettyText.cook("```custom foo=bar\ncustom content\n```")).to match_html("
custom content
") + expect(PrettyText.cook("```INVALID a=1\n```")).to match_html("
\n
") + expect(PrettyText.cook("```INVALID a=1, foo=bar , baz=2\n```")).to match_html("
\n
") + expect(PrettyText.cook("```text\n```")).to match_html("
\n
") expect(PrettyText.cook("```auto\n```")).to match_html("
\n
") expect(PrettyText.cook("```ruby startline=3 $%@#\n```")).to match_html("
\n
") - expect(PrettyText.cook("```mermaid a_-你=17\n```")).to match_html("
\n
") - expect(PrettyText.cook("```mermaid foo=\n```")).to match_html("
\n
") - expect(PrettyText.cook("```mermaid foo=‮ begin admin o\n```")).to match_html("
\n
") + expect(PrettyText.cook("```mermaid a_-你=17\n```")).to match_html("
\n
") + expect(PrettyText.cook("```mermaid foo=\n```")).to match_html("
\n
") + expect(PrettyText.cook("```mermaid foo=‮ begin admin o\n```")).to match_html("
\n
") expect(PrettyText.cook("```c++\nc++\n```")).to match_html("
c++\n
") expect(PrettyText.cook("```structured-text\nstructured-text\n```")).to match_html("
structured-text\n
") expect(PrettyText.cook("```p21\np21\n```")).to match_html("
p21\n
")