From 07ae07dca38b9b68f8e610c2fb4dc7ffe328aa8f Mon Sep 17 00:00:00 2001 From: Brett Walker <bwalker@gitlab.com> Date: Fri, 21 Oct 2022 17:20:45 -0500 Subject: [PATCH] Move SyntaxHighlightFilter to end of pipelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to minimize it’s changes on the html earlier in the pipeline. --- .../output_example_snapshots/html.yml | 198 +++++++++--------- lib/banzai/filter/math_filter.rb | 9 +- lib/banzai/filter/syntax_highlight_filter.rb | 45 ++-- lib/banzai/pipeline/ascii_doc_pipeline.rb | 2 +- lib/banzai/pipeline/gfm_pipeline.rb | 4 +- .../markdown_golden_master_examples.yml | 14 +- spec/lib/banzai/filter/math_filter_spec.rb | 10 +- .../filter/syntax_highlight_filter_spec.rb | 22 +- spec/lib/gitlab/asciidoc_spec.rb | 19 +- 9 files changed, 167 insertions(+), 156 deletions(-) diff --git a/glfm_specification/output_example_snapshots/html.yml b/glfm_specification/output_example_snapshots/html.yml index 69cff67d27d3e..a16ee2e720020 100644 --- a/glfm_specification/output_example_snapshots/html.yml +++ b/glfm_specification/output_example_snapshots/html.yml @@ -2,22 +2,22 @@ 02_01_00__preliminaries__tabs__001: canonical: "<pre><code>foo\tbaz\t\tbim\n</code></pre>\n" static: "<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre - data-sourcepos=\"1:2-1:13\" class=\"code highlight js-syntax-highlight language-plaintext\" - lang=\"plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" + data-sourcepos=\"1:2-1:13\" lang=\"plaintext\" class=\"code highlight js-syntax-highlight + language-plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" class=\"line\" lang=\"plaintext\">foo\tbaz\t\tbim</span></code></pre>\n<copy-code></copy-code>\n</div>" wysiwyg: "<pre class=\"content-editor-code-block undefined code highlight\"><code>foo\tbaz\t\tbim</code></pre>" 02_01_00__preliminaries__tabs__002: canonical: "<pre><code>foo\tbaz\t\tbim\n</code></pre>\n" static: "<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre - data-sourcepos=\"1:4-1:15\" class=\"code highlight js-syntax-highlight language-plaintext\" - lang=\"plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" + data-sourcepos=\"1:4-1:15\" lang=\"plaintext\" class=\"code highlight js-syntax-highlight + language-plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" class=\"line\" lang=\"plaintext\">foo\tbaz\t\tbim</span></code></pre>\n<copy-code></copy-code>\n</div>" wysiwyg: "<pre class=\"content-editor-code-block undefined code highlight\"><code>foo\tbaz\t\tbim</code></pre>" 02_01_00__preliminaries__tabs__003: canonical: "<pre><code>a\ta\ná½\ta\n</code></pre>\n" static: "<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre - data-sourcepos=\"1:5-2:9\" class=\"code highlight js-syntax-highlight language-plaintext\" - lang=\"plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" + data-sourcepos=\"1:5-2:9\" lang=\"plaintext\" class=\"code highlight js-syntax-highlight + language-plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" class=\"line\" lang=\"plaintext\">a\ta</span>\n<span id=\"LC2\" class=\"line\" lang=\"plaintext\">á½\ta</span></code></pre>\n<copy-code></copy-code>\n</div>" wysiwyg: "<pre class=\"content-editor-code-block undefined code highlight\"><code>a\ta\ná½\ta</code></pre>" @@ -52,7 +52,7 @@ <li data-sourcepos="1:1-3:5"> <p data-sourcepos="1:3-1:5">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:2-3:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> bar</span></code></pre> + <pre data-sourcepos="3:2-3:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> bar</span></code></pre> <copy-code></copy-code> </div> </li> @@ -68,7 +68,7 @@ static: |- <blockquote data-sourcepos="1:1-1:6" dir="auto"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:3-1:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span></code></pre> + <pre data-sourcepos="1:3-1:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span></code></pre> <copy-code></copy-code> </div> </blockquote> @@ -86,7 +86,7 @@ <ul data-sourcepos="1:1-1:6" dir="auto"> <li data-sourcepos="1:1-1:6"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:3-1:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span></code></pre> + <pre data-sourcepos="1:3-1:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span></code></pre> <copy-code></copy-code> </div> </li> @@ -100,7 +100,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-2:4" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span> + <pre data-sourcepos="1:5-2:4" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span> <span id="LC2" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> @@ -221,7 +221,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">***</span></code></pre> + <pre data-sourcepos="1:5-1:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">***</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -464,7 +464,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"># foo</span></code></pre> + <pre data-sourcepos="1:5-1:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"># foo</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -661,7 +661,7 @@ <hr /> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-4:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">Foo</span> + <pre data-sourcepos="1:5-4:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">Foo</span> <span id="LC2" class="line" lang="plaintext">---</span> <span id="LC3" class="line" lang="plaintext"></span> <span id="LC4" class="line" lang="plaintext">Foo</span></code></pre> @@ -806,7 +806,7 @@ <p>Baz</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-yaml" lang="yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="s">Foo</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="yaml" class="code highlight js-syntax-highlight language-yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="s">Foo</span></span></code></pre> <copy-code></copy-code> </div> <h2 data-sourcepos="4:1-6:3" dir="auto"> @@ -829,7 +829,7 @@ <hr /> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-2:3" class="code highlight js-syntax-highlight language-yaml" lang="yaml" data-lang-params="frontmatter" v-pre="true"><code></code></pre> + <pre data-sourcepos="1:1-2:3" lang="yaml" class="code highlight js-syntax-highlight language-yaml" data-lang-params="frontmatter" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -855,7 +855,7 @@ <hr /> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:5-1:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> <hr data-sourcepos="2:1-2:3"> @@ -953,7 +953,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-2:25" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">a simple</span> + <pre data-sourcepos="1:5-2:25" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">a simple</span> <span id="LC2" class="line" lang="plaintext"> indented code block</span></code></pre> <copy-code></copy-code> </div> @@ -1007,7 +1007,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-4:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><a/></span> + <pre data-sourcepos="1:5-4:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><a/></span> <span id="LC2" class="line" lang="plaintext">*hi*</span> <span id="LC3" class="line" lang="plaintext"></span> <span id="LC4" class="line" lang="plaintext">- one</span></code></pre> @@ -1030,7 +1030,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-7:10" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">chunk1</span> + <pre data-sourcepos="1:5-7:10" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">chunk1</span> <span id="LC2" class="line" lang="plaintext"></span> <span id="LC3" class="line" lang="plaintext">chunk2</span> <span id="LC4" class="line" lang="plaintext"></span> @@ -1051,7 +1051,7 @@ canonical: "<pre><code>chunk1\n \n chunk2\n</code></pre>\n" static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-3:12" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">chunk1</span> + <pre data-sourcepos="1:5-3:12" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">chunk1</span> <span id="LC2" class="line" lang="plaintext"> </span> <span id="LC3" class="line" lang="plaintext"> chunk2</span></code></pre> <copy-code></copy-code> @@ -1075,7 +1075,7 @@ <p>bar</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:5-1:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="2:1-2:3" dir="auto">bar</p> @@ -1095,13 +1095,13 @@ <h1 data-sourcepos="1:1-1:9" dir="auto"> <a id="user-content-heading" class="anchor" href="#heading" aria-hidden="true"></a>Heading</h1> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="2:5-2:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="2:5-2:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> <h2 data-sourcepos="3:1-5:7" dir="auto"> <a id="user-content-heading-1" class="anchor" href="#heading-1" aria-hidden="true"></a>Heading</h2> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:5-5:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="5:5-5:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> <hr data-sourcepos="6:1-6:4"> @@ -1118,7 +1118,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-2:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span> + <pre data-sourcepos="1:5-2:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> foo</span> <span id="LC2" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> @@ -1131,7 +1131,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:5-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="3:5-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1140,7 +1140,7 @@ canonical: "<pre><code>foo \n</code></pre>\n" static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo </span></code></pre> + <pre data-sourcepos="1:5-1:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo </span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1152,7 +1152,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><</span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><</span> <span id="LC2" class="line" lang="plaintext"> ></span></code></pre> <copy-code></copy-code> </div> @@ -1166,7 +1166,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><</span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><</span> <span id="LC2" class="line" lang="plaintext"> ></span></code></pre> <copy-code></copy-code> </div> @@ -1187,7 +1187,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">~~~</span></code></pre> <copy-code></copy-code> </div> @@ -1201,7 +1201,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">```</span></code></pre> <copy-code></copy-code> </div> @@ -1215,7 +1215,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-4:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">```</span></code></pre> <copy-code></copy-code> </div> @@ -1229,7 +1229,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:4" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-4:4" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">~~~</span></code></pre> <copy-code></copy-code> </div> @@ -1241,7 +1241,7 @@ <pre><code></code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-1:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> + <pre data-sourcepos="1:1-1:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1254,7 +1254,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> <span id="LC2" class="line" lang="plaintext">```</span> <span id="LC3" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> @@ -1273,7 +1273,7 @@ static: |- <blockquote data-sourcepos="1:1-2:5" dir="auto"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:3-3:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> + <pre data-sourcepos="1:3-3:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> </div> </blockquote> @@ -1285,7 +1285,7 @@ canonical: "<pre><code>\n \n</code></pre>\n" static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> + <pre data-sourcepos="1:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> <span id="LC2" class="line" lang="plaintext"> </span></code></pre> <copy-code></copy-code> </div> @@ -1296,7 +1296,7 @@ <pre><code></code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-2:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> + <pre data-sourcepos="1:1-2:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1308,7 +1308,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:2-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:2-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> </div> @@ -1323,7 +1323,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:3-5:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:3-5:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">aaa</span> <span id="LC3" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> @@ -1340,7 +1340,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:4-5:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:4-5:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext"> aaa</span> <span id="LC3" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> @@ -1357,7 +1357,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-3:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">```</span> + <pre data-sourcepos="1:5-3:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">```</span> <span id="LC2" class="line" lang="plaintext">aaa</span> <span id="LC3" class="line" lang="plaintext">```</span></code></pre> <copy-code></copy-code> @@ -1372,7 +1372,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> + <pre data-sourcepos="1:1-3:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1383,7 +1383,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:4-3:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> + <pre data-sourcepos="1:4-3:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1395,7 +1395,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-3:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext"> ```</span></code></pre> <copy-code></copy-code> </div> @@ -1419,7 +1419,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> + <pre data-sourcepos="1:1-3:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span> <span id="LC2" class="line" lang="plaintext">~~~ ~~</span></code></pre> <copy-code></copy-code> </div> @@ -1435,7 +1435,7 @@ static: |- <p data-sourcepos="1:1-1:3" dir="auto">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="2:1-4:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="2:1-4:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="5:1-5:3" dir="auto">baz</p> @@ -1453,7 +1453,7 @@ <h2 data-sourcepos="1:1-3:3" dir="auto"> <a id="user-content-foo" class="anchor" href="#foo" aria-hidden="true"></a>foo</h2> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:1-5:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="3:1-5:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> <h1 data-sourcepos="6:1-6:5" dir="auto"> @@ -1470,7 +1470,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-5:3" class="code highlight js-syntax-highlight language-ruby" lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></span> + <pre data-sourcepos="1:1-5:3" lang="ruby" class="code highlight js-syntax-highlight language-ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></span> <span id="LC2" class="line" lang="ruby"> <span class="k">return</span> <span class="mi">3</span></span> <span id="LC3" class="line" lang="ruby"><span class="k">end</span></span></code></pre> <copy-code></copy-code> @@ -1487,7 +1487,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-5:7" class="code highlight js-syntax-highlight language-ruby" lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></span> + <pre data-sourcepos="1:1-5:7" lang="ruby" class="code highlight js-syntax-highlight language-ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></span> <span id="LC2" class="line" lang="ruby"> <span class="k">return</span> <span class="mi">3</span></span> <span id="LC3" class="line" lang="ruby"><span class="k">end</span></span></code></pre> <copy-code></copy-code> @@ -1501,7 +1501,7 @@ <pre><code class="language-;"></code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-2:4" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang=";" v-pre="true"><code></code></pre> + <pre data-sourcepos="1:1-2:4" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang=";" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1522,7 +1522,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="aa" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="aa" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1533,7 +1533,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">``` aaa</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">``` aaa</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -1799,7 +1799,7 @@ <p>okay</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> + <pre lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span> <span id="LC2" class="line" lang="plaintext">import Text.HTML.TagSoup</span> <span id="LC3" class="line" lang="plaintext"></span> <span id="LC4" class="line" lang="plaintext">main :: IO ()</span> @@ -1989,8 +1989,8 @@ <pre><code><!-- foo --> </code></pre> static: " \n<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre - data-sourcepos=\"3:5-3:16\" class=\"code highlight js-syntax-highlight language-plaintext\" - lang=\"plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" + data-sourcepos=\"3:5-3:16\" lang=\"plaintext\" class=\"code highlight js-syntax-highlight + language-plaintext\" data-canonical-lang=\"\" v-pre=\"true\"><code><span id=\"LC1\" class=\"line\" lang=\"plaintext\"><!-- foo --></span></code></pre>\n<copy-code></copy-code>\n</div>" wysiwyg: |- <pre class="content-editor-code-block undefined code highlight"><code><!-- foo --></code></pre> @@ -2002,7 +2002,7 @@ static: |2- <div> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:5-3:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><div></span></code></pre> + <pre data-sourcepos="3:5-3:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><div></span></code></pre> <copy-code></copy-code> </div> </div> @@ -2113,7 +2113,7 @@ <table dir="auto"> <tr> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:5-8:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><td></span> + <pre data-sourcepos="5:5-8:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"><td></span> <span id="LC2" class="line" lang="plaintext"> Hi</span> <span id="LC3" class="line" lang="plaintext"></td></span></code></pre> <copy-code></copy-code> @@ -2306,7 +2306,7 @@ <p>[foo]</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-2:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">[foo]: /url "title"</span></code></pre> + <pre data-sourcepos="1:5-2:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">[foo]: /url "title"</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="3:1-3:5" dir="auto">[foo]</p> @@ -2320,7 +2320,7 @@ <p>[foo]</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">[foo]: /url</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">[foo]: /url</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="5:1-5:5" dir="auto">[foo]</p> @@ -2489,7 +2489,7 @@ <p>bbb</p> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> + <pre data-sourcepos="1:5-1:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">aaa</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="2:1-2:3" dir="auto">bbb</p> @@ -2836,7 +2836,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-3:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">> # Foo</span> + <pre data-sourcepos="1:5-3:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">> # Foo</span> <span id="LC2" class="line" lang="plaintext">> bar</span> <span id="LC3" class="line" lang="plaintext">> baz</span></code></pre> <copy-code></copy-code> @@ -2926,12 +2926,12 @@ static: |- <blockquote data-sourcepos="1:1-1:9" dir="auto"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:7-1:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:7-1:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> </blockquote> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="2:5-2:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="2:5-2:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -2947,13 +2947,13 @@ static: |- <blockquote data-sourcepos="1:1-1:5" dir="auto"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:3-2:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> + <pre data-sourcepos="1:3-2:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> </blockquote> <p data-sourcepos="2:1-2:3" dir="auto">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> + <pre data-sourcepos="3:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -3184,7 +3184,7 @@ static: |- <blockquote data-sourcepos="1:1-1:10" dir="auto"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:7-1:10" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">code</span></code></pre> + <pre data-sourcepos="1:7-1:10" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">code</span></code></pre> <copy-code></copy-code> </div> </blockquote> @@ -3207,7 +3207,7 @@ <p data-sourcepos="1:1-2:15" dir="auto">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:5-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:5-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:1-6:16" dir="auto"> @@ -3237,7 +3237,7 @@ <p data-sourcepos="1:5-2:19">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:9-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:9-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:5-6:20"> @@ -3291,7 +3291,7 @@ <li data-sourcepos="1:2-2:0">one</li> </ul> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:5-3:8" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> two</span></code></pre> + <pre data-sourcepos="3:5-3:8" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> two</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -3405,7 +3405,7 @@ <li data-sourcepos="1:1-9:9"> <p data-sourcepos="1:5-1:7">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:5-5:7" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="3:5-5:7" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="7:5-7:7">baz</p> @@ -3433,7 +3433,7 @@ <li data-sourcepos="1:1-6:9"> <p data-sourcepos="1:3-1:5">Foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:7-6:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span> + <pre data-sourcepos="3:7-6:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span> <span id="LC2" class="line" lang="plaintext"></span> <span id="LC3" class="line" lang="plaintext"></span> <span id="LC4" class="line" lang="plaintext">baz</span></code></pre> @@ -3507,7 +3507,7 @@ <li data-sourcepos="1:1-3:9"> <p data-sourcepos="1:3-1:5">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:7-3:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="3:7-3:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> </li> @@ -3528,7 +3528,7 @@ <li data-sourcepos="1:3-3:14"> <p data-sourcepos="1:8-1:10">foo</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:12-3:14" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="3:12-3:14" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> </li> @@ -3544,12 +3544,12 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-2:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="1:5-2:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="3:1-3:9" dir="auto">paragraph</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:5-5:13" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> + <pre data-sourcepos="5:5-5:13" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -3571,12 +3571,12 @@ <ol data-sourcepos="1:1-5:16" dir="auto"> <li data-sourcepos="1:1-5:16"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:8-2:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="1:8-2:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="3:4-3:12">paragraph</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:8-5:16" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> + <pre data-sourcepos="5:8-5:16" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> <copy-code></copy-code> </div> </li> @@ -3598,12 +3598,12 @@ <ol data-sourcepos="1:1-5:16" dir="auto"> <li data-sourcepos="1:1-5:16"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:8-2:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> indented code</span></code></pre> + <pre data-sourcepos="1:8-2:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> indented code</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="3:4-3:12">paragraph</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:8-5:16" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> + <pre data-sourcepos="5:8-5:16" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">more code</span></code></pre> <copy-code></copy-code> </div> </li> @@ -3669,13 +3669,13 @@ <li data-sourcepos="1:1-2:5">foo</li> <li data-sourcepos="3:1-6:5"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:3-6:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> + <pre data-sourcepos="4:3-6:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">bar</span></code></pre> <copy-code></copy-code> </div> </li> <li data-sourcepos="7:1-8:9"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="8:7-8:9" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">baz</span></code></pre> + <pre data-sourcepos="8:7-8:9" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">baz</span></code></pre> <copy-code></copy-code> </div> </li> @@ -3803,7 +3803,7 @@ <p data-sourcepos="1:6-2:20">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:10-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:10-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:6-6:21"> @@ -3833,7 +3833,7 @@ <p data-sourcepos="1:7-2:21">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:11-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:11-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:7-6:22"> @@ -3863,7 +3863,7 @@ <p data-sourcepos="1:8-2:22">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:12-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:12-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:8-6:23"> @@ -3885,7 +3885,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-6:24" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">1. A paragraph</span> + <pre data-sourcepos="1:5-6:24" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">1. A paragraph</span> <span id="LC2" class="line" lang="plaintext"> with two lines.</span> <span id="LC3" class="line" lang="plaintext"></span> <span id="LC4" class="line" lang="plaintext"> indented code</span> @@ -3919,7 +3919,7 @@ <p data-sourcepos="1:7-2:15">A paragraph with two lines.</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="4:11-5:0" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> + <pre data-sourcepos="4:11-5:0" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">indented code</span></code></pre> <copy-code></copy-code> </div> <blockquote data-sourcepos="6:7-6:22"> @@ -4345,7 +4345,7 @@ </ul> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="9:5-9:8" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">code</span></code></pre> + <pre data-sourcepos="9:5-9:8" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">code</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -4443,7 +4443,7 @@ </li> </ol> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:5-5:8" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">3. c</span></code></pre> + <pre data-sourcepos="5:5-5:8" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">3. c</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -4573,7 +4573,7 @@ <li data-sourcepos="1:1-1:3">a</li> <li data-sourcepos="2:1-6:5"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="2:3-6:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">b</span> + <pre data-sourcepos="2:3-6:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">b</span> <span id="LC2" class="line" lang="plaintext"></span> <span id="LC3" class="line" lang="plaintext"></span></code></pre> <copy-code></copy-code> @@ -4650,7 +4650,7 @@ <p data-sourcepos="2:5-2:5">b</p> </blockquote> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="3:3-5:5" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">c</span></code></pre> + <pre data-sourcepos="3:3-5:5" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">c</span></code></pre> <copy-code></copy-code> </div> </li> @@ -4701,7 +4701,7 @@ <ol data-sourcepos="1:1-5:6" dir="auto"> <li data-sourcepos="1:1-5:6"> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:4-3:6" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:4-3:6" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> <p data-sourcepos="5:4-5:6">bar</p> @@ -4848,7 +4848,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:8" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">\[\]</span></code></pre> + <pre data-sourcepos="1:5-1:8" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">\[\]</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -4859,7 +4859,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">\[\]</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">\[\]</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -4899,7 +4899,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="foo+bar" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="foo+bar" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -4989,7 +4989,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="föö" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="föö" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">foo</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -5007,7 +5007,7 @@ </code></pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:5-1:18" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">f&ouml;f&ouml;</span></code></pre> + <pre data-sourcepos="1:5-1:18" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">f&ouml;f&ouml;</span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -7741,7 +7741,7 @@ </pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-yaml" lang="yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="na">title</span><span class="pi">:</span> <span class="s">YAML front matter</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="yaml" class="code highlight js-syntax-highlight language-yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="na">title</span><span class="pi">:</span> <span class="s">YAML front matter</span></span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -7755,7 +7755,7 @@ </pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-toml" lang="toml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="toml"><span class="err">title:</span> <span class="err">TOML</span> <span class="err">front</span> <span class="err">matter</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="toml" class="code highlight js-syntax-highlight language-toml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="toml"><span class="err">title:</span> <span class="err">TOML</span> <span class="err">front</span> <span class="err">matter</span></span></code></pre> <copy-code></copy-code> </div> wysiwyg: |- @@ -7771,7 +7771,7 @@ </pre> static: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-5:3" class="code highlight js-syntax-highlight language-json" lang="json" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="json"><span class="p">{</span></span> + <pre data-sourcepos="1:1-5:3" lang="json" class="code highlight js-syntax-highlight language-json" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="json"><span class="p">{</span></span> <span id="LC2" class="line" lang="json"><span class="w"> </span><span class="nl">"title"</span><span class="p">:</span><span class="w"> </span><span class="s2">"JSON front matter"</span></span> <span id="LC3" class="line" lang="json"><span class="p">}</span></span></code></pre> <copy-code></copy-code> diff --git a/lib/banzai/filter/math_filter.rb b/lib/banzai/filter/math_filter.rb index ca13a8d6474df..ac00900804048 100644 --- a/lib/banzai/filter/math_filter.rb +++ b/lib/banzai/filter/math_filter.rb @@ -10,7 +10,7 @@ module Filter # HTML filter that implements our math syntax, adding class="code math" # class MathFilter < HTML::Pipeline::Filter - CSS_MATH = 'pre.code.language-math' + CSS_MATH = 'pre[lang="math"] > code' XPATH_MATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_MATH).freeze CSS_CODE = 'code' XPATH_CODE = Gitlab::Utils::Nokogiri.css_to_xpath(CSS_CODE).freeze @@ -125,9 +125,10 @@ def process_dollar_backtick_inline # corresponds to the "```math...```" syntax def process_math_codeblock - doc.xpath(XPATH_MATH).each do |el| - el[STYLE_ATTRIBUTE] = 'display' - el[:class] += " #{TAG_CLASS}" + doc.xpath(XPATH_MATH).each do |node| + pre_node = node.parent + pre_node[STYLE_ATTRIBUTE] = 'display' + pre_node[:class] = TAG_CLASS end end diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb index 7175e99f1c7d1..230a1ee24feb4 100644 --- a/lib/banzai/filter/syntax_highlight_filter.rb +++ b/lib/banzai/filter/syntax_highlight_filter.rb @@ -13,8 +13,9 @@ class SyntaxHighlightFilter < HTML::Pipeline::Filter LANG_PARAMS_DELIMITER = ':' LANG_PARAMS_ATTR = 'data-lang-params' + CSS_CLASSES = 'code highlight js-syntax-highlight' - CSS = 'pre:not([data-math-style]):not([data-mermaid-style]):not([data-kroki-style]) > code:only-child' + CSS = 'pre:not([data-kroki-style]) > code:only-child' XPATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze def call @@ -26,9 +27,7 @@ def call end def highlight_node(node) - css_classes = +'code highlight js-syntax-highlight' lang, lang_params = parse_lang_params(node) - sourcepos = node.parent.attr('data-sourcepos') retried = false if use_rouge?(lang) @@ -41,7 +40,6 @@ def highlight_node(node) begin code = Rouge::Formatters::HTMLGitlab.format(lex(lexer, node.text), tag: language) - css_classes << " language-#{language}" if language rescue StandardError # Gracefully handle syntax highlighter bugs/errors to ensure users can # still access an issue/comment/etc. First, retry with the plain text @@ -56,16 +54,26 @@ def highlight_node(node) retry end - sourcepos_attr = sourcepos ? "data-sourcepos=\"#{escape_once(sourcepos)}\"" : '' + # maintain existing attributes already added. e.g math and mermaid nodes + node.children = code + pre_node = node.parent - highlighted = %(<div class="gl-relative markdown-code-block js-markdown-code"><pre #{sourcepos_attr} class="#{css_classes}" - lang="#{language}" - #{lang != language ? "data-canonical-lang=\"#{escape_once(lang)}\"" : ""} - #{lang_params} - v-pre="true"><code>#{code}</code></pre><copy-code></copy-code></div>) + # ensure there are no extra children, such as a text node that might + # show up from an XSS attack + pre_node.children = node + + pre_node[:lang] = language + pre_node.add_class(CSS_CLASSES) + pre_node.add_class("language-#{language}") if language + pre_node.set_attribute('data-canonical-lang', escape_once(lang)) if lang != language + pre_node.set_attribute(LANG_PARAMS_ATTR, escape_once(lang_params)) if lang_params.present? + pre_node.set_attribute('v-pre', 'true') + pre_node.remove_attribute('data-meta') + + highlighted = %(<div class="gl-relative markdown-code-block js-markdown-code">#{pre_node.to_html}<copy-code></copy-code></div>) # Extracted to a method to measure it - replace_parent_pre_element(node, highlighted) + replace_pre_element(pre_node, highlighted) end private @@ -93,9 +101,8 @@ def parse_lang_params(node) language, language_params = language.split(LANG_PARAMS_DELIMITER, 2) language_params = [node.attr('data-meta'), language_params].compact.join(' ') - formatted_language_params = format_language_params(language_params) - [language, formatted_language_params] + [language, language_params] end # Separate method so it can be instrumented. @@ -107,20 +114,14 @@ def lexer_for(language) (Rouge::Lexer.find(language) || Rouge::Lexers::PlainText).new end - # Replace the parent `pre` element with the entire highlighted block - def replace_parent_pre_element(node, highlighted) - node.parent.replace(highlighted) + # Replace the `pre` element with the entire highlighted block + def replace_pre_element(pre_node, highlighted) + pre_node.replace(highlighted) end def use_rouge?(language) (%w(math suggestion) + ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES).exclude?(language) end - - def format_language_params(language_params) - return if language_params.blank? - - %(#{LANG_PARAMS_ATTR}="#{escape_once(language_params)}") - end end end end diff --git a/lib/banzai/pipeline/ascii_doc_pipeline.rb b/lib/banzai/pipeline/ascii_doc_pipeline.rb index b652d8d89cfae..afd5802de2250 100644 --- a/lib/banzai/pipeline/ascii_doc_pipeline.rb +++ b/lib/banzai/pipeline/ascii_doc_pipeline.rb @@ -7,13 +7,13 @@ def self.filters FilterArray[ Filter::AsciiDocSanitizationFilter, Filter::AssetProxyFilter, - Filter::SyntaxHighlightFilter, Filter::ExternalLinkFilter, Filter::PlantumlFilter, Filter::ColorFilter, Filter::ImageLazyLoadFilter, Filter::ImageLinkFilter, Filter::WikiLinkFilter, + Filter::SyntaxHighlightFilter, Filter::AsciiDocPostProcessingFilter ] end diff --git a/lib/banzai/pipeline/gfm_pipeline.rb b/lib/banzai/pipeline/gfm_pipeline.rb index 5e7c2f64c92fb..9b73e413d44cf 100644 --- a/lib/banzai/pipeline/gfm_pipeline.rb +++ b/lib/banzai/pipeline/gfm_pipeline.rb @@ -17,7 +17,6 @@ def self.filters Filter::SanitizationFilter, Filter::KrokiFilter, Filter::AssetProxyFilter, - Filter::SyntaxHighlightFilter, Filter::MathFilter, Filter::ColorFilter, Filter::MermaidFilter, @@ -37,7 +36,8 @@ def self.filters Filter::CustomEmojiFilter, Filter::TaskListFilter, Filter::InlineDiffFilter, - Filter::SetDirectionFilter + Filter::SetDirectionFilter, + Filter::SyntaxHighlightFilter ] end diff --git a/spec/fixtures/markdown/markdown_golden_master_examples.yml b/spec/fixtures/markdown/markdown_golden_master_examples.yml index 6a1e75348cfbc..0c7e6ab5cd212 100644 --- a/spec/fixtures/markdown/markdown_golden_master_examples.yml +++ b/spec/fixtures/markdown/markdown_golden_master_examples.yml @@ -297,7 +297,7 @@ ``` html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">hello world</span><span class="dl">'</span><span class="p">)</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="javascript" class="code highlight js-syntax-highlight language-javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">hello world</span><span class="dl">'</span><span class="p">)</span></span></code></pre> <copy-code></copy-code> </div> @@ -308,7 +308,7 @@ ``` html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> plaintext</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> plaintext</span></code></pre> <copy-code></copy-code> </div> @@ -319,7 +319,7 @@ ``` html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="foobar" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> custom_language = >> this <<</span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="foobar" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"> custom_language = >> this <<</span></code></pre> <copy-code></copy-code> </div> @@ -531,7 +531,7 @@ ;;; html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-5:3" class="code highlight js-syntax-highlight language-json" lang="json" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="json"><span class="p">{</span></span> + <pre data-sourcepos="1:1-5:3" lang="json" class="code highlight js-syntax-highlight language-json" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="json"><span class="p">{</span></span> <span id="LC2" class="line" lang="json"><span class="w"> </span><span class="nl">"title"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Page title"</span></span> <span id="LC3" class="line" lang="json"><span class="p">}</span></span></code></pre> <copy-code></copy-code> @@ -544,7 +544,7 @@ +++ html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-toml" lang="toml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="toml"><span class="py">title</span> <span class="p">=</span> <span class="s">"Page title"</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="toml" class="code highlight js-syntax-highlight language-toml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="toml"><span class="py">title</span> <span class="p">=</span> <span class="s">"Page title"</span></span></code></pre> <copy-code></copy-code> </div> @@ -555,7 +555,7 @@ --- html: |- <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-yaml" lang="yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="na">title</span><span class="pi">:</span> <span class="s">Page title</span></span></code></pre> + <pre data-sourcepos="1:1-3:3" lang="yaml" class="code highlight js-syntax-highlight language-yaml" data-lang-params="frontmatter" v-pre="true"><code><span id="LC1" class="line" lang="yaml"><span class="na">title</span><span class="pi">:</span> <span class="s">Page title</span></span></code></pre> <copy-code></copy-code> </div> @@ -690,7 +690,7 @@ <p data-sourcepos="1:1-1:36" dir="auto">This math is inline <code class="code math js-render-math" data-math-style="inline">a^2+b^2=c^2</code>.</p> <p data-sourcepos="3:1-3:27" dir="auto">This is on a separate line:</p> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre data-sourcepos="5:1-7:3" class="code highlight js-syntax-highlight language-math js-render-math" lang="math" v-pre="true" data-math-style="display"><code><span id="LC1" class="line" lang="math">a^2+b^2=c^2</span></code></pre> + <pre data-sourcepos="5:1-7:3" lang="math" data-math-style="display" class="js-render-math code highlight js-syntax-highlight language-math" v-pre="true"><code><span id="LC1" class="line" lang="math">a^2+b^2=c^2</span></code></pre> <copy-code></copy-code> </div> diff --git a/spec/lib/banzai/filter/math_filter_spec.rb b/spec/lib/banzai/filter/math_filter_spec.rb index 350ac1edbe1ae..c5d2bcd5363ae 100644 --- a/spec/lib/banzai/filter/math_filter_spec.rb +++ b/spec/lib/banzai/filter/math_filter_spec.rb @@ -111,35 +111,35 @@ describe 'display math using ```math...``` syntax' do it 'adds data-math-style display attribute to display math' do - doc = filter('<pre class="code highlight js-syntax-highlight language-math" v-pre="true"><code>2+2</code></pre>') + doc = filter('<pre lang="math"><code>2+2</code></pre>') pre = doc.xpath('descendant-or-self::pre').first expect(pre['data-math-style']).to eq 'display' end it 'adds js-render-math class to display math' do - doc = filter('<pre class="code highlight js-syntax-highlight language-math" v-pre="true"><code>2+2</code></pre>') + doc = filter('<pre lang="math"><code>2+2</code></pre>') pre = doc.xpath('descendant-or-self::pre').first expect(pre[:class]).to include("js-render-math") end it 'ignores code blocks that are not math' do - input = '<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true"><code>2+2</code></pre>' + input = '<pre lang="plaintext"><code>2+2</code></pre>' doc = filter(input) expect(doc.to_s).to eq input end it 'requires the pre to contain both code and math' do - input = '<pre class="highlight js-syntax-highlight language-plaintext language-math" v-pre="true"><code>2+2</code></pre>' + input = '<pre lang="math">something</pre>' doc = filter(input) expect(doc.to_s).to eq input end it 'dollar signs around to display math' do - doc = filter('$<pre class="code highlight js-syntax-highlight language-math" v-pre="true"><code>2+2</code></pre>$') + doc = filter('$<pre lang="math"><code>2+2</code></pre>$') before = doc.xpath('descendant-or-self::text()[1]').first after = doc.xpath('descendant-or-self::text()[3]').first diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index 33adca0ddfcf6..d188a40c53e81 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -23,7 +23,7 @@ it "highlights as plaintext" do result = filter('<pre><code>def fun end</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">def fun end</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">def fun end</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "" @@ -31,9 +31,9 @@ context "when contains mermaid diagrams" do it "ignores mermaid blocks" do - result = filter('<pre data-mermaid-style="display"><code>mermaid code</code></pre>') + result = filter('<pre data-mermaid-style="display" lang="mermaid"><code class="js-render-mermaid">mermaid code</code></pre>') - expect(result.to_html).to eq('<pre data-mermaid-style="display"><code>mermaid code</code></pre>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-mermaid-style="display" lang="mermaid" class="code highlight js-syntax-highlight language-mermaid" v-pre="true"><code class="js-render-mermaid"><span id="LC1" class="line" lang="mermaid">mermaid code</span></code></pre><copy-code></copy-code></div>') end end @@ -49,7 +49,7 @@ it "highlights as that language" do result = filter('<pre lang="ruby"><code>def fun end</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-ruby" lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">fun</span> <span class="k">end</span></span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="ruby" class="code highlight js-syntax-highlight language-ruby" v-pre="true"><code><span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">fun</span> <span class="k">end</span></span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "ruby" @@ -59,7 +59,7 @@ it "highlights as plaintext" do result = filter('<pre lang="gnuplot"><code>This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="gnuplot" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="gnuplot" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "gnuplot" @@ -74,7 +74,7 @@ it "highlights as plaintext but with the correct language attribute and class" do result = filter(%{<pre lang="#{lang}"><code>This is a test</code></pre>}) - expect(result.to_html.delete("\n")).to eq(%{<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-#{lang}" lang="#{lang}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>}) + expect(result.to_html.delete("\n")).to eq(%{<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="#{lang}" class="code highlight js-syntax-highlight language-#{lang}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>}) end include_examples "XSS prevention", lang @@ -87,7 +87,7 @@ it "includes data-lang-params tag with extra information" do result = filter(%{<pre lang="#{lang}" data-meta="#{lang_params}"><code>This is a test</code></pre>}) - expect(result.to_html.delete("\n")).to eq(%{<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-#{lang}" lang="#{lang}" #{data_attr}="#{lang_params}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>}) + expect(result.to_html.delete("\n")).to eq(%{<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="#{lang}" class="code highlight js-syntax-highlight language-#{lang}" #{data_attr}="#{lang_params}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>}) end include_examples "XSS prevention", lang @@ -105,7 +105,7 @@ let(:lang_params) { '-1+10' } let(:expected_result) do - %{<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-#{lang}" lang="#{lang}" #{data_attr}="#{lang_params} more-things" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>} + %{<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="#{lang}" class="code highlight js-syntax-highlight language-#{lang}" #{data_attr}="#{lang_params} more-things" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre><copy-code></copy-code></div>} end context 'when delimiter is space' do @@ -130,13 +130,13 @@ it "includes it in the highlighted code block" do result = filter('<pre data-sourcepos="1:1-3:3"><code lang="plaintext">This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos="1:1-3:3" lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code lang="plaintext"><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') end it "escape sourcepos metadata to prevent XSS" do result = filter('<pre data-sourcepos=""%22 href="x"></pre><base href=http://unsafe-website.com/><pre x=""><code></code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos=\'"%22 href="x"></pre><base href=http://unsafe-website.com/><pre x="\' class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos=\'"%22 href="x"></pre><base href=http://unsafe-website.com/><pre x="\' lang="plaintext" class="code highlight js-syntax-highlight language-plaintext" data-canonical-lang="" v-pre="true"><code></code></pre><copy-code></copy-code></div>') end end @@ -150,7 +150,7 @@ it "highlights as plaintext" do result = filter('<pre lang="ruby"><code>This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight" lang="" data-canonical-lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre lang="" class="code highlight js-syntax-highlight" data-canonical-lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="">This is a test</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "ruby" diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 8fec8bce23e36..7ef1d7619f97d 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -94,9 +94,18 @@ module Gitlab # Move this test back to the items hash when removing `use_cmark_renderer` feature flag. it "does not convert dangerous fenced code with inline script into HTML" do input = '```mypre"><script>alert(3)</script>' - output = "<div>\n<div>\n<div class=\"gl-relative markdown-code-block js-markdown-code\">\n<pre class=\"code highlight js-syntax-highlight language-plaintext\" lang=\"plaintext\" data-canonical-lang=\"mypre\" v-pre=\"true\"><code></code></pre>\n<copy-code></copy-code>\n</div>\n</div>\n</div>" + output = <<~HTML + <div> + <div> + <div class=\"gl-relative markdown-code-block js-markdown-code\"> + <pre lang=\"plaintext\" class=\"code highlight js-syntax-highlight language-plaintext\" data-canonical-lang=\"mypre\" v-pre=\"true\"><code></code></pre> + <copy-code></copy-code> + </div> + </div> + </div> + HTML - expect(render(input, context)).to include(output) + expect(render(input, context)).to include(output.strip) end it 'does not allow locked attributes to be overridden' do @@ -360,7 +369,7 @@ module Gitlab <div> <div> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre class="code highlight js-syntax-highlight language-javascript" lang="javascript" data-canonical-lang="js" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">hello world</span><span class="dl">'</span><span class="p">)</span></span></code></pre> + <pre lang="javascript" class="code highlight js-syntax-highlight language-javascript" data-canonical-lang="js" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">hello world</span><span class="dl">'</span><span class="p">)</span></span></code></pre> <copy-code></copy-code> </div> </div> @@ -390,7 +399,7 @@ module Gitlab <div>class.cpp</div> <div> <div class="gl-relative markdown-code-block js-markdown-code"> - <pre class="code highlight js-syntax-highlight language-cpp" lang="cpp" data-canonical-lang="c++" v-pre="true"><code><span id="LC1" class="line" lang="cpp"><span class="cp">#include</span> <span class="cpf"><stdio.h></span></span> + <pre lang="cpp" class="code highlight js-syntax-highlight language-cpp" data-canonical-lang="c++" v-pre="true"><code><span id="LC1" class="line" lang="cpp"><span class="cp">#include</span> <span class="cpf"><stdio.h></span></span> <span id="LC2" class="line" lang="cpp"></span> <span id="LC3" class="line" lang="cpp"><span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="mi">5</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span></span> <span id="LC4" class="line" lang="cpp"> <span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="o"><<</span><span class="s">"*"</span><span class="o"><<</span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span></span> @@ -448,7 +457,7 @@ module Gitlab stem:[2+2] is 4 MD - expect(render(input, context)).to include('<pre data-math-style="display" class="code math js-render-math"><code>eta_x gamma</code></pre>') + expect(render(input, context)).to include('<pre data-math-style="display" lang="plaintext" class="code math js-render-math" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">eta_x gamma</span></code></pre>') expect(render(input, context)).to include('<p><code data-math-style="inline" class="code math js-render-math">2+2</code> is 4</p>') end end -- GitLab