Skip to content

Commit

Permalink
Update build to be compatible with node 14 and fix bug in higlight co…
Browse files Browse the repository at this point in the history
…de in Kotlin
  • Loading branch information
javamind committed Nov 5, 2020
1 parent dca56b4 commit 5cce687
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions extension/highlight-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ function extHighlightCode(_a) {
return html
.replace(/&amp;lt<span class="token punctuation">;<\/span>/g, '&lt;')
.replace(/&amp;gt<span class="token punctuation">;<\/span>/g, '&gt;')
.replace(/&amp;quot<span class="token punctuation">;<\/span>/g, '&quot;')
.replace(/&amp;pos<span class="token punctuation">;<\/span>/g, '&pos;')
.replace(/<span class=\"token operator\">&amp;<\/span>quot<span class=\"token punctuation\">;<\/span>/g, '&quot;')
.replace(/<span class=\"token operator\">&amp;<\/span>lt<span class=\"token punctuation\">;<\/span>/g, '&lt;')
.replace(/<span class=\"token operator\">&amp;<\/span>apos<span class=\"token punctuation\">;<\/span>/g, '&apos;')
.replace(/<span class=\"token operator\">&amp;<\/span>gt<span class=\"token punctuation\">;<\/span>/g, '&gt;')
.replace(/<span class=\"token operator\">&amp;<\/span>gt<span class=\"token punctuation\">;<\/span>/g, '&gt;');
};
return through2.obj(function (file, _, next) {
Expand Down
20 changes: 12 additions & 8 deletions extension/highlight-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ const loadLanguages = require('prismjs/components/');
export function extHighlightCode({selector}): Transform {

const updateSpecialCharacters = (html) => {
return html
.replace(/&amp;lt<span class="token punctuation">;<\/span>/g, '&lt;')
.replace(/&amp;gt<span class="token punctuation">;<\/span>/g, '&gt;')
.replace(/<span class=\"token operator\">&amp;<\/span>quot<span class=\"token punctuation\">;<\/span>/g, '&quot;')
.replace(/<span class=\"token operator\">&amp;<\/span>lt<span class=\"token punctuation\">;<\/span>/g, '&lt;')
.replace(/<span class=\"token operator\">&amp;<\/span>apos<span class=\"token punctuation\">;<\/span>/g, '&apos;')
.replace(/<span class=\"token operator\">&amp;<\/span>gt<span class=\"token punctuation\">;<\/span>/g, '&gt;')
return html
.replace(/&amp;lt<span class="token punctuation">;<\/span>/g, '&lt;')
.replace(/&amp;gt<span class="token punctuation">;<\/span>/g, '&gt;')
.replace(/&amp;quot<span class="token punctuation">;<\/span>/g, '&quot;')
.replace(/&amp;pos<span class="token punctuation">;<\/span>/g, '&pos;')
.replace(/<span class=\"token operator\">&amp;<\/span>quot<span class=\"token punctuation\">;<\/span>/g, '&quot;')
.replace(/<span class=\"token operator\">&amp;<\/span>lt<span class=\"token punctuation\">;<\/span>/g, '&lt;')
.replace(/<span class=\"token operator\">&amp;<\/span>apos<span class=\"token punctuation\">;<\/span>/g, '&apos;')
.replace(/<span class=\"token operator\">&amp;<\/span>gt<span class=\"token punctuation\">;<\/span>/g, '&gt;')
.replace(/<span class=\"token operator\">&amp;<\/span>gt<span class=\"token punctuation\">;<\/span>/g, '&gt;')
};

return through2.obj((file, _, next: TransformCallback) => {
Expand All @@ -26,7 +29,8 @@ export function extHighlightCode({selector}): Transform {
lowerCaseTags: false,
withEndIndices: false,
normalizeWhitespace: false,
recognizeSelfClosing:true});
recognizeSelfClosing: true
});

$(selector).each((index, code) => {
const elem = $(code);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"AsciiDoc"
],
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},
"author": "Guillaume EHRET <Dev-Mind>",
"license": "MIT",
Expand Down
8 changes: 8 additions & 0 deletions src/blog/2018/test2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ class MainActivity : AppCompatActivity() {
}
}
----

[source,kotlin,subs="specialchars"]
----
fun main(){
val name = "Dev-Mind"
println("Hello world $name")
}
----

0 comments on commit 5cce687

Please sign in to comment.