diff options
-rw-r--r-- | lib/utils/page.js | 7 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | test/books/highlight/README.md | 3 | ||||
-rw-r--r-- | test/codehighlighting.js | 9 | ||||
-rw-r--r-- | test/plugins/replace_highlight/index.js | 5 |
5 files changed, 20 insertions, 6 deletions
diff --git a/lib/utils/page.js b/lib/utils/page.js index a17c6a2..2c57421 100644 --- a/lib/utils/page.js +++ b/lib/utils/page.js @@ -244,14 +244,15 @@ function normalizeHtml(src, options) { .value(); var source = $(this).text(); - var html = options.book.template.applyBlock("code", { + var blk = options.book.template.applyBlock("code", { body: source, kwargs: { language: lang } - }).body; + }); - $(this).html(html); + if (blk.html === false) $(this).text(blk.body); + else $(this).html(blk.body); }); // Replace glossary terms diff --git a/package.json b/package.json index 079ea09..15a100d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "fs-extra": "0.16.5", "fstream-ignore": "1.0.2", "gitbook-parsers": "0.8.2", - "gitbook-plugin-highlight": "1.0.2", + "gitbook-plugin-highlight": "1.0.3", "nunjucks": "mozilla/nunjucks#dc89bf91611a2101731c2c06afcf5c32160b4dc9", "nunjucks-autoescape": "1.0.0", "nunjucks-filter": "1.0.0", diff --git a/test/books/highlight/README.md b/test/books/highlight/README.md index 417fabc..f47ac83 100644 --- a/test/books/highlight/README.md +++ b/test/books/highlight/README.md @@ -12,4 +12,5 @@ Block with a language test 2 ``` -Inline code: `test 3`
\ No newline at end of file +Inline code: `test 3` +Inline code with html: `<test>`
\ No newline at end of file diff --git a/test/codehighlighting.js b/test/codehighlighting.js index d79fc85..9f392af 100644 --- a/test/codehighlighting.js +++ b/test/codehighlighting.js @@ -52,5 +52,14 @@ describe("Code Highlighting", function () { } }); }); + + it("should correctly replace highlighting for inline code with html tags", function() { + PAGE.should.be.html({ + "code": { + index: 3, + text: "code_<test>_code" + } + }); + }); }); diff --git a/test/plugins/replace_highlight/index.js b/test/plugins/replace_highlight/index.js index 2e8f71d..8586486 100644 --- a/test/plugins/replace_highlight/index.js +++ b/test/plugins/replace_highlight/index.js @@ -4,7 +4,10 @@ module.exports = { process: function(blk) { var lang = blk.kwargs.language || "code"; - return lang+"_"+blk.body+"_"+lang; + return { + body: lang+"_"+blk.body+"_"+lang, + html: false + }; } } } |