From 8275f4e62f8ea2953de6b90cb51ef2df05a66860 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 23 Jul 2020 15:05:55 -0700 Subject: [PATCH 1/3] Default hljs language to html --- helpers/code.js | 1 + helpers/markdown.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/helpers/code.js b/helpers/code.js index d7d5d89..0ebded0 100644 --- a/helpers/code.js +++ b/helpers/code.js @@ -11,6 +11,7 @@ var hljs = require('highlight.js'); */ module.exports = function(language, options) { if (typeof language === 'undefined') language = 'html'; + language = hljs.getLanguage(language) ? language : 'html'; var code = hljs.highlight(language, options.fn(this)).value; diff --git a/helpers/markdown.js b/helpers/markdown.js index f01b4a0..e6ec5f9 100644 --- a/helpers/markdown.js +++ b/helpers/markdown.js @@ -15,6 +15,8 @@ var marked = require('marked'); renderer.code = function(code, language) { if (typeof language === 'undefined') language = 'html'; + language = hljs.getLanguage(language) ? language : 'html'; + var renderedCode = hljs.highlight(language, code).value; var output = `
${renderedCode}
`; From 5a0a4d5ba5340dda9e8c9e21f7d3ff7ee0610049 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 23 Jul 2020 15:22:21 -0700 Subject: [PATCH 2/3] test for markdown + code highlights closes #220 --- test/fixtures/helper-markdown/build/index.html | 2 +- test/fixtures/helper-markdown/expected/index.html | 2 +- test/fixtures/helper-markdown/pages/index.html | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/fixtures/helper-markdown/build/index.html b/test/fixtures/helper-markdown/build/index.html index e889a3b..c8ec16b 100644 --- a/test/fixtures/helper-markdown/build/index.html +++ b/test/fixtures/helper-markdown/build/index.html @@ -2,6 +2,6 @@

Heading

Paragraph

- +
my code block should default to html
.class{color:red}
diff --git a/test/fixtures/helper-markdown/expected/index.html b/test/fixtures/helper-markdown/expected/index.html index e889a3b..c8ec16b 100644 --- a/test/fixtures/helper-markdown/expected/index.html +++ b/test/fixtures/helper-markdown/expected/index.html @@ -2,6 +2,6 @@

Heading

Paragraph

- +
my code block should default to html
.class{color:red}
diff --git a/test/fixtures/helper-markdown/pages/index.html b/test/fixtures/helper-markdown/pages/index.html index cd16fc0..28a646e 100644 --- a/test/fixtures/helper-markdown/pages/index.html +++ b/test/fixtures/helper-markdown/pages/index.html @@ -2,4 +2,12 @@ # Heading Paragraph + +``` +my code block should default to html +``` + +```css +.class{color:red} +``` {{/markdown}} From 5376e6654d5559818b12fc1c91022ad04aac0ed7 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 23 Jul 2020 15:22:57 -0700 Subject: [PATCH 3/3] udpate version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28665ac..74d3d29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "panini", - "version": "1.7.0", + "version": "1.7.1", "description": "A super tiny flat file compiler.", "main": "index.js", "scripts": {