From 894aec9db3bc66c701acad4065c11538a3236e0e Mon Sep 17 00:00:00 2001 From: openorclose Date: Sun, 15 Mar 2020 19:28:37 +0800 Subject: [PATCH 1/2] Use
to separate lines of code block --- asset/css/markbind.css | 2 +- src/lib/markbind/src/lib/markdown-it/index.js | 6 ++---- .../test_site/expected/markbind/css/markbind.css | 2 +- .../requirements/UserStories._include_.html | 2 +- .../test_site/expected/testCodeBlocks.html | 16 ++++++++-------- .../test_site/expected/testTooltipSpacing.html | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../test_default/expected/index.html | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- 13 files changed, 21 insertions(+), 23 deletions(-) diff --git a/asset/css/markbind.css b/asset/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/asset/css/markbind.css +++ b/asset/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/src/lib/markbind/src/lib/markdown-it/index.js b/src/lib/markbind/src/lib/markdown-it/index.js index a22717f39c..7c85879892 100644 --- a/src/lib/markbind/src/lib/markdown-it/index.js +++ b/src/lib/markbind/src/lib/markdown-it/index.js @@ -108,8 +108,6 @@ markdownIt.renderer.rules.fence = (tokens, idx, options, env, slf) => { lines.pop(); // last line is always a single '\n' newline, so we remove it // wrap all lines with so we can number them str = lines.map((line, index) => { - // if a line is empty we put a 0 width non breaking space - const content = line || '​'; const currentLineNumber = index + 1; // check if there is at least one range or line number that matches the current line number // Note: The algorithm is based off markdown-it-highlight-lines (https://github.com/egoist/markdown-it-highlight-lines/blob/master/src/index.js) @@ -123,9 +121,9 @@ markdownIt.renderer.rules.fence = (tokens, idx, options, env, slf) => { return currentLineNumber === start; }); if (inRange) { - return `${content}`; + return `${line}
`; } - return `${content}`; + return `${line}
`; }).join(''); token.attrJoin('class', 'hljs'); diff --git a/test/functional/test_site/expected/markbind/css/markbind.css b/test/functional/test_site/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site/expected/markbind/css/markbind.css +++ b/test/functional/test_site/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site/expected/requirements/UserStories._include_.html b/test/functional/test_site/expected/requirements/UserStories._include_.html index 72cb964f89..debc4deaf4 100644 --- a/test/functional/test_site/expected/requirements/UserStories._include_.html +++ b/test/functional/test_site/expected/requirements/UserStories._include_.html @@ -2,7 +2,7 @@

A commonly used format for writing user stories is:
As a <use type/role> I can <function> so that <benefit>

Here are some examples of user stories for the IVLE system:

-
* As a student, I can download files uploaded by lecturers, so that I can get my own copy of the files.* As a lecturer, I can create discussion forums, so that students can discuss things online.* As a tutor, I can print attendance sheets, so that I can take attendance during the class.
+
* As a student, I can download files uploaded by lecturers, so that I can get my own copy of the files.
* As a lecturer, I can create discussion forums, so that students can discuss things online.
* As a tutor, I can print attendance sheets, so that I can take attendance during the class.

The <benefit> can be omitted if it is obvious. E.g. As a tutor, I can print attendance sheets. User stories are mainly used for early estimation and scheduling purposes.

According to this diff --git a/test/functional/test_site/expected/testCodeBlocks.html b/test/functional/test_site/expected/testCodeBlocks.html index d6ca3bb6e6..1e2e3f52ab 100644 --- a/test/functional/test_site/expected/testCodeBlocks.html +++ b/test/functional/test_site/expected/testCodeBlocks.html @@ -27,29 +27,29 @@

Code blocks test

Multiple linebreaks, no highlight

-
Four empty lines belowFour empty lines above
+
Four empty lines below




Four empty lines above

Multiple linebreaks, with highlight

-
function fourEmptyLinesBelow() {} // four empty lines above
+
function fourEmptyLinesBelow() {




} // four empty lines above

hljs span spanning multiple lines

-
*****-----
+
*****
-----

start-from attr causes inline style to be set

-
*****-----
+
*****
-----

highlight-lines attr causes corresponding lines to have 'highlighted' class

-
1  highlighted23  highlighted45  highlighted6  highlighted7  highlighted8  highlighted910
+
1  highlighted
2
3 highlighted
4
5 highlighted
6 highlighted
7 highlighted
8 highlighted
9
10

highlight-lines attr with start-from attr cause corresponding lines to have 'highlighted' class based on 'start-from'

-
11  highlighted1213  highlighted1415  highlighted16  highlighted17  highlighted18  highlighted1920
+
11  highlighted
12
13 highlighted
14
15 highlighted
16 highlighted
17 highlighted
18 highlighted
19
20

Code block heading

A heading
-
<foo>    <bar></foo>
+
<foo>
<bar>
</foo>

Code block heading with inline markdown

Bold, Italic, Bold and Italic, Strike through, Super Bold, Underline, Highlight, 👍 ❗️ ❌ 🚧
We support page breaks
-
<foo>    <bar></foo>
+
<foo>
<bar>
</foo>
diff --git a/test/functional/test_site/expected/testTooltipSpacing.html b/test/functional/test_site/expected/testTooltipSpacing.html index 2a2091df61..0122cc7f8f 100644 --- a/test/functional/test_site/expected/testTooltipSpacing.html +++ b/test/functional/test_site/expected/testTooltipSpacing.html @@ -26,7 +26,7 @@

569: Stray space after tooltip

-
<tooltip>tooltip</tooltip>, test<trigger>trigger</trigger>, test
+
<tooltip>tooltip</tooltip>, test

<trigger>trigger</trigger>, test

tooltip, test

trigger, test

diff --git a/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css b/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css +++ b/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_convert/expected/markbind/css/markbind.css b/test/functional/test_site_convert/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_convert/expected/markbind/css/markbind.css +++ b/test/functional/test_site_convert/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css b/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css +++ b/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_special_tags/expected/markbind/css/markbind.css b/test/functional/test_site_special_tags/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_special_tags/expected/markbind/css/markbind.css +++ b/test/functional/test_site_special_tags/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_templates/test_default/expected/index.html b/test/functional/test_site_templates/test_default/expected/index.html index 22d35f8e5f..adab17c507 100644 --- a/test/functional/test_site_templates/test_default/expected/index.html +++ b/test/functional/test_site_templates/test_default/expected/index.html @@ -87,7 +87,7 @@

Heading 1

A code example:

-
<foo>  <bar type="name">goo</bar></foo>
+
<foo>
<bar type="name">goo</bar>
</foo>

Sub Heading 1.1

A ❗️ some important explanationtooltip, a modal, a link, diff --git a/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css b/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css +++ b/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css b/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css index e21c7c4808..1f15bc2409 100644 --- a/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css +++ b/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: block; + display: inline-block; } .hljs:not(.inline):not(.no-line-numbers) > span { From 9c03fd76c00960ec169250db79e26c00194b72e1 Mon Sep 17 00:00:00 2001 From: openorclose Date: Sun, 5 Apr 2020 09:14:37 +0800 Subject: [PATCH 2/2] Put
inside span instead of outside --- asset/css/markbind.css | 2 +- src/lib/markbind/src/lib/markdown-it/index.js | 4 ++-- .../test_site/expected/markbind/css/markbind.css | 2 +- .../requirements/UserStories._include_.html | 2 +- .../test_site/expected/testCodeBlocks.html | 16 ++++++++-------- .../test_site/expected/testTooltipSpacing.html | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../test_default/expected/index.html | 2 +- .../expected/markbind/css/markbind.css | 2 +- .../expected/markbind/css/markbind.css | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/asset/css/markbind.css b/asset/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/asset/css/markbind.css +++ b/asset/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/src/lib/markbind/src/lib/markdown-it/index.js b/src/lib/markbind/src/lib/markdown-it/index.js index 7c85879892..5ca37d86f7 100644 --- a/src/lib/markbind/src/lib/markdown-it/index.js +++ b/src/lib/markbind/src/lib/markdown-it/index.js @@ -121,9 +121,9 @@ markdownIt.renderer.rules.fence = (tokens, idx, options, env, slf) => { return currentLineNumber === start; }); if (inRange) { - return `${line}
`; + return `${line}
`; } - return `${line}
`; + return `${line}
`; }).join(''); token.attrJoin('class', 'hljs'); diff --git a/test/functional/test_site/expected/markbind/css/markbind.css b/test/functional/test_site/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site/expected/markbind/css/markbind.css +++ b/test/functional/test_site/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site/expected/requirements/UserStories._include_.html b/test/functional/test_site/expected/requirements/UserStories._include_.html index debc4deaf4..6a3393c007 100644 --- a/test/functional/test_site/expected/requirements/UserStories._include_.html +++ b/test/functional/test_site/expected/requirements/UserStories._include_.html @@ -2,7 +2,7 @@

A commonly used format for writing user stories is:
As a <use type/role> I can <function> so that <benefit>

Here are some examples of user stories for the IVLE system:

-
* As a student, I can download files uploaded by lecturers, so that I can get my own copy of the files.
* As a lecturer, I can create discussion forums, so that students can discuss things online.
* As a tutor, I can print attendance sheets, so that I can take attendance during the class.
+
* As a student, I can download files uploaded by lecturers, so that I can get my own copy of the files.
* As a lecturer, I can create discussion forums, so that students can discuss things online.
* As a tutor, I can print attendance sheets, so that I can take attendance during the class.

The <benefit> can be omitted if it is obvious. E.g. As a tutor, I can print attendance sheets. User stories are mainly used for early estimation and scheduling purposes.

According to this diff --git a/test/functional/test_site/expected/testCodeBlocks.html b/test/functional/test_site/expected/testCodeBlocks.html index 1e2e3f52ab..2e7578c66d 100644 --- a/test/functional/test_site/expected/testCodeBlocks.html +++ b/test/functional/test_site/expected/testCodeBlocks.html @@ -27,29 +27,29 @@

Code blocks test

Multiple linebreaks, no highlight

-
Four empty lines below




Four empty lines above
+
Four empty lines below




Four empty lines above

Multiple linebreaks, with highlight

-
function fourEmptyLinesBelow() {




} // four empty lines above
+
function fourEmptyLinesBelow() {




} // four empty lines above

hljs span spanning multiple lines

-
*****
-----
+
*****
-----

start-from attr causes inline style to be set

-
*****
-----
+
*****
-----

highlight-lines attr causes corresponding lines to have 'highlighted' class

-
1  highlighted
2
3 highlighted
4
5 highlighted
6 highlighted
7 highlighted
8 highlighted
9
10
+
1  highlighted
2
3 highlighted
4
5 highlighted
6 highlighted
7 highlighted
8 highlighted
9
10

highlight-lines attr with start-from attr cause corresponding lines to have 'highlighted' class based on 'start-from'

-
11  highlighted
12
13 highlighted
14
15 highlighted
16 highlighted
17 highlighted
18 highlighted
19
20
+
11  highlighted
12
13 highlighted
14
15 highlighted
16 highlighted
17 highlighted
18 highlighted
19
20

Code block heading

A heading
-
<foo>
<bar>
</foo>
+
<foo>
<bar>
</foo>

Code block heading with inline markdown

Bold, Italic, Bold and Italic, Strike through, Super Bold, Underline, Highlight, 👍 ❗️ ❌ 🚧
We support page breaks
-
<foo>
<bar>
</foo>
+
<foo>
<bar>
</foo>
diff --git a/test/functional/test_site/expected/testTooltipSpacing.html b/test/functional/test_site/expected/testTooltipSpacing.html index 0122cc7f8f..ec22327bd8 100644 --- a/test/functional/test_site/expected/testTooltipSpacing.html +++ b/test/functional/test_site/expected/testTooltipSpacing.html @@ -26,7 +26,7 @@

569: Stray space after tooltip

-
<tooltip>tooltip</tooltip>, test

<trigger>trigger</trigger>, test
+
<tooltip>tooltip</tooltip>, test

<trigger>trigger</trigger>, test

tooltip, test

trigger, test

diff --git a/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css b/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css +++ b/test/functional/test_site_algolia_plugin/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_convert/expected/markbind/css/markbind.css b/test/functional/test_site_convert/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_convert/expected/markbind/css/markbind.css +++ b/test/functional/test_site_convert/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css b/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css +++ b/test/functional/test_site_expressive_layout/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_special_tags/expected/markbind/css/markbind.css b/test/functional/test_site_special_tags/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_special_tags/expected/markbind/css/markbind.css +++ b/test/functional/test_site_special_tags/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_templates/test_default/expected/index.html b/test/functional/test_site_templates/test_default/expected/index.html index adab17c507..706b806726 100644 --- a/test/functional/test_site_templates/test_default/expected/index.html +++ b/test/functional/test_site_templates/test_default/expected/index.html @@ -87,7 +87,7 @@

Heading 1

A code example:

-
<foo>
<bar type="name">goo</bar>
</foo>
+
<foo>
<bar type="name">goo</bar>
</foo>

Sub Heading 1.1

A ❗️ some important explanationtooltip, a modal, a link, diff --git a/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css b/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css +++ b/test/functional/test_site_templates/test_default/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span { diff --git a/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css b/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css index 1f15bc2409..e21c7c4808 100644 --- a/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css +++ b/test/functional/test_site_templates/test_minimal/expected/markbind/css/markbind.css @@ -351,7 +351,7 @@ li.footnote-item:target { } .hljs:not(.inline) > span { - display: inline-block; + display: block; } .hljs:not(.inline):not(.no-line-numbers) > span {