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}
`; 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": { 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}}