diff options
author | mrBrutus <[omitted]> | 2020-02-16 15:02:37 +0300 |
---|---|---|
committer | mrBrutus <[omitted]> | 2020-02-16 15:02:37 +0300 |
commit | fe6a1254ebbc124c3a5a4942a62f75e82ab486c5 (patch) | |
tree | 2d4bf2954fc81276596b88816747b21635e33236 | |
parent | 361d226c924c0520f20d0131a47028c39fd4d87b (diff) |
enable Highlight.js line numbers and -highlights
-rw-r--r-- | exampleSite/config.toml | 6 | ||||
-rw-r--r-- | layouts/partials/reveal-hugo/slides.html | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index d835452..50dd6a7 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -20,8 +20,12 @@ name = "Josh Dzielak" [markup.goldmark.renderer] unsafe = true [markup.highlight] +# setting the theme for highlighting by Hugo # we need a style that looks good in both light and dark background! style = "tango" +# to allow the use of Highlight.js line numbers and highlights +# (see https://github.com/hakimel/reveal.js#line-numbers--highlights) +codeFences = false [outputFormats.Reveal] baseName = "index" @@ -30,6 +34,8 @@ isHTML = true [params.reveal_hugo] history = true +# setting the theme for highlighting by Highlight.js +highlight_theme = "github" # used in content/template-example [params.reveal_hugo.templates.grey] diff --git a/layouts/partials/reveal-hugo/slides.html b/layouts/partials/reveal-hugo/slides.html index d1157b2..0bed8a9 100644 --- a/layouts/partials/reveal-hugo/slides.html +++ b/layouts/partials/reveal-hugo/slides.html @@ -6,7 +6,11 @@ {{- $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" -}} <!-- <code> blocks processed by Hugo's highlighter have a data-lang attribute. For those, we disable --> <!-- highlight.js by changing the language class to "nohighlight", and adding "data-noescape". --> - {{- $content := replaceRE `<code class="language-\w+"\s+data-lang="\w+"` `<code class="nohighlight" data-noescape` $content -}} + {{- $content := replaceRE `<code class="language-\w+"\s+data-lang="\w+"` `<code class="nohighlight" data-noescape` $content -}} + <!-- enable Highlight.js line numbers when the markdown code block language selection is followed by "{}" e.g. ```js{} --> + {{- $content := replaceRE `(<code class="language-\w+){}(">)` `$1" data-line-numbers>` $content -}} + <!-- enable Highlight.js line highlights when the language selection is followed by "{<line numbers>}" e.g. ```js{1,5-7} --> + {{- $content := replaceRE `(<code class="language-\w+){(\S+)}(">)` `$1" data-line-numbers="$2">` $content -}} <!-- Support both <hr /> (blackfriday) and <hr> (mmark) --> {{- $content := replace $content "<hr>" "<hr />" -}} <!-- Split the processed content by <hr /> tag --> |