From 1cd81ff8875596d4ce6af0def9ff1883e27083f9 Mon Sep 17 00:00:00 2001 From: Dima Fitiskin Date: Thu, 11 Aug 2016 12:39:49 +0400 Subject: [PATCH 1/2] Store data attributes in unescaped markup plugin. For example data-start for line-numbers plugin. --- plugins/unescaped-markup/prism-unescaped-markup.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/unescaped-markup/prism-unescaped-markup.js b/plugins/unescaped-markup/prism-unescaped-markup.js index ab3059a745..ad1eb63aad 100644 --- a/plugins/unescaped-markup/prism-unescaped-markup.js +++ b/plugins/unescaped-markup/prism-unescaped-markup.js @@ -22,6 +22,14 @@ pre.className = code.className = env.element.className; + if (env.element.dataset) { + Object.keys(env.element.dataset).forEach(function (key) { + if (Object.prototype.hasOwnProperty.call(env.element.dataset, key)) { + pre.dataset[key] = env.element.dataset[key]; + } + }); + } + env.code = env.code.replace(/<\/script(>|>)/gi, ""); code.textContent = env.code; From 8ddcc964c27fa32f66b18de5fd86fa56ebd4fa36 Mon Sep 17 00:00:00 2001 From: Dima Fitiskin Date: Thu, 11 Aug 2016 12:42:28 +0400 Subject: [PATCH 2/2] Fix removing line-numbers class form code. It removes space between other classes in code. --- plugins/line-numbers/index.html | 12 +++++++++++- plugins/line-numbers/prism-line-numbers.js | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/line-numbers/index.html b/plugins/line-numbers/index.html index 2d01694901..415a35f8fa 100644 --- a/plugins/line-numbers/index.html +++ b/plugins/line-numbers/index.html @@ -44,6 +44,14 @@

HTML

Please note the data-start="-5" in the code below.


 
+	

Inline HTML unescaped

+

Please note the data-start="10" in the code below.

+ +

Unknown languages

This raw text
 is not highlighted
@@ -55,10 +63,12 @@ 

Unknown languages

+ + - \ No newline at end of file + diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js index b01ce6feae..116df8cc1a 100644 --- a/plugins/line-numbers/prism-line-numbers.js +++ b/plugins/line-numbers/prism-line-numbers.js @@ -27,7 +27,7 @@ Prism.hooks.add('complete', function (env) { if (clsReg.test(env.element.className)) { // Remove the class "line-numbers" from the - env.element.className = env.element.className.replace(clsReg, ''); + env.element.className = env.element.className.replace(clsReg, ' '); } if (!clsReg.test(pre.className)) { // Add the class "line-numbers" to the
@@ -54,4 +54,4 @@ Prism.hooks.add('complete', function (env) {
 
 });
 
-}());
\ No newline at end of file
+}());