From a6337a77d56c93efc6ff5ddf70980e3da131d35b Mon Sep 17 00:00:00 2001 From: Labayna Neil Brian Narido Date: Sat, 21 Mar 2020 19:22:34 +0800 Subject: [PATCH] Code blocks: Implement inline markdown support for heading Remove console log and rename var Update docs increase line-heigh for headings with inline md remove line remove br update tests change css structure update tests update tests and css class name Add tests Address comments Update docs/userGuide/syntax/code.mbdf Co-Authored-By: Daryl Tan <3646725+openorclose@users.noreply.github.com> --- asset/css/markbind.css | 4 ++++ docs/userGuide/syntax/code.mbdf | 19 +++++++++++++++++++ src/lib/markbind/src/lib/markdown-it/index.js | 4 +++- .../expected/markbind/css/markbind.css | 4 ++++ .../test_site/expected/testCodeBlocks.html | 14 ++++++++++++++ test/functional/test_site/testCodeBlocks.md | 16 ++++++++++++++++ .../expected/markbind/css/markbind.css | 4 ++++ .../expected/markbind/css/markbind.css | 4 ++++ .../expected/markbind/css/markbind.css | 4 ++++ .../expected/markbind/css/markbind.css | 4 ++++ .../expected/markbind/css/markbind.css | 4 ++++ .../expected/markbind/css/markbind.css | 4 ++++ 12 files changed, 84 insertions(+), 1 deletion(-) diff --git a/asset/css/markbind.css b/asset/css/markbind.css index bcf1cd275a..9334f9d900 100644 --- a/asset/css/markbind.css +++ b/asset/css/markbind.css @@ -46,6 +46,10 @@ pre > code.hljs[heading] { text-align: right; } +.inline-markdown-heading { + line-height: 1.5; +} + .code-block-content { clear: both; display: block; diff --git a/docs/userGuide/syntax/code.mbdf b/docs/userGuide/syntax/code.mbdf index cfb76b9c83..d30752f700 100644 --- a/docs/userGuide/syntax/code.mbdf +++ b/docs/userGuide/syntax/code.mbdf @@ -149,6 +149,25 @@ To add a heading, add the attribute `heading` with the heading text as the value +Headings support inline Markdown, except for `Inline Code` and %%Dim%% text styles. + + + + +```` {.no-line-numbers} +```{heading="**Bold**, _Italic_, ___Bold and Italic___, ~~Strike through~~, ****Super Bold****, ++Underline++, ==Highlight==, :+1: :exclamation: :x: :construction:
We support page breaks"} + +``` +```` +
+ + +```{heading="**Bold**, _Italic_, ___Bold and Italic___, ~~Strike through~~, ****Super Bold****, ++Underline++, ==Highlight==, :+1: :exclamation: :x: :construction:
We support page breaks"} + +``` +
+
+ ##### Using multiple features You can also use multiple features together, as shown below. diff --git a/src/lib/markbind/src/lib/markdown-it/index.js b/src/lib/markbind/src/lib/markdown-it/index.js index 3f057dee21..a22717f39c 100644 --- a/src/lib/markbind/src/lib/markdown-it/index.js +++ b/src/lib/markbind/src/lib/markdown-it/index.js @@ -136,8 +136,10 @@ markdownIt.renderer.rules.fence = (tokens, idx, options, env, slf) => { const heading = token.attrGet('heading'); const codeBlockContent = `
${str}
`; if (heading) { + const renderedHeading = markdownIt.renderInline(heading); + const headingStyle = (renderedHeading === heading) ? 'code-block-heading' : 'code-block-heading inline-markdown-heading'; return '
' - + `
${heading}
` + + `
${renderedHeading}
` + `
${codeBlockContent}
` + '
'; } diff --git a/test/functional/test_site/expected/markbind/css/markbind.css b/test/functional/test_site/expected/markbind/css/markbind.css index bcf1cd275a..9334f9d900 100644 --- a/test/functional/test_site/expected/markbind/css/markbind.css +++ b/test/functional/test_site/expected/markbind/css/markbind.css @@ -46,6 +46,10 @@ pre > code.hljs[heading] { text-align: right; } +.inline-markdown-heading { + line-height: 1.5; +} + .code-block-content { clear: both; display: block; diff --git a/test/functional/test_site/expected/testCodeBlocks.html b/test/functional/test_site/expected/testCodeBlocks.html index 46a7829fc7..56feb259b8 100644 --- a/test/functional/test_site/expected/testCodeBlocks.html +++ b/test/functional/test_site/expected/testCodeBlocks.html @@ -38,6 +38,20 @@
1  highlighted23  highlighted45  highlighted6  highlighted7  highlighted8  highlighted910

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
+

Code block heading

+
+
A heading
+
+
<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>
+
+