192 lines
7.7 KiB
HTML
192 lines
7.7 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Reveal.js 3.9.0 highlighting example</title>
|
|
|
|
<meta name="author" content="Josh Dzielak">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<link rel="stylesheet" href="./reveal-js/css/reset.css">
|
|
<link rel="stylesheet" href="./reveal-js/css/reveal.css"><link rel="stylesheet" href="./reveal-js/css/theme/white.css" id="theme">
|
|
<link rel="stylesheet" href="./highlight-js/vs.min.css">
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="reveal">
|
|
<div class="slides">
|
|
|
|
|
|
<section><h2 id="multiline-highlighting-with-highlightjs">Multiline highlighting with Highlight.js</h2>
|
|
</section><section>
|
|
<p>This presentation shows the use of the <a href="https://github.com/hakimel/reveal.js/blob/master/README.md#step-by-step-highlights">new highlighting features</a> which were introduced with Reveal.js <a href="https://github.com/hakimel/reveal.js/releases/tag/3.9.0">v3.9.0</a>.</p>
|
|
</section><section>
|
|
<h2 id="prerequisite">Prerequisite</h2>
|
|
<p>Disable <code>codeFences</code> in to your <code>config.toml</code> to prevent Hugo’s built-in highlighting for code inside of <code>---</code> fences.</p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>[markup.highlight]
|
|
codeFences = <span style="color:#000;font-weight:bold">false</span></code></pre></div>
|
|
</section><section>
|
|
<h2 id="theme">Theme</h2>
|
|
<p>Specify a theme for Highlight.js in <code>config.toml</code></p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>[params.reveal_hugo]
|
|
highlight_theme = <span style="color:#d14">"github"</span></code></pre></div>
|
|
</section><section>
|
|
<p>…or in the <code>_index.md</code> front matter</p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>[reveal_hugo]
|
|
highlight_theme = <span style="color:#d14">"github"</span></code></pre></div>
|
|
</section><section>
|
|
<h2 id="usage">Usage</h2>
|
|
<p>The line highlighting is configured by adding <code>{}</code> immediately after the language selection of the markdown code block.</p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>
|
|
```foo{}
|
|
|
|
```</code></pre></div>
|
|
</section><section>
|
|
<h2 id="just-line-numbers">Just line numbers</h2>
|
|
<p><code>{}</code></p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>
|
|
```go{}
|
|
package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
```</code></pre></div>
|
|
<pre><code class="language-go" data-line-numbers>package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
</code></pre>
|
|
</section><section>
|
|
<h2 id="highlight-specific-lines">Highlight specific lines</h2>
|
|
<p><code>{<line numbers separated by comma>}</code></p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>```go{1,3-5}
|
|
package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
```</code></pre></div>
|
|
<pre><code class="language-go" data-line-numbers="1,3-5">package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
</code></pre>
|
|
</section><section>
|
|
<h2 id="multi-step-highlight">Multi step highlight</h2>
|
|
<p><code>{<line numbers separated by pipe>}</code></p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape>```go{1|2|3-5}
|
|
package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
```</code></pre></div>
|
|
<pre><code class="language-go" data-line-numbers="1|2|3-5">package main
|
|
import "fmt"
|
|
func main() {
|
|
fmt.Println("Hello world!")
|
|
}
|
|
</code></pre>
|
|
</section><section>
|
|
<h2 id="hiding-the-line-numbers">Hiding the line numbers</h2>
|
|
<p>There is no Reveal.js parameter to use line highlighting <em>without</em> line numbers.
|
|
However it can be achieved by adding the some <a href="https://github.com/dzello/reveal-hugo#adding-html-to-the-layout">custom CSS</a>.</p>
|
|
<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="nohighlight" data-noescape><<span style="color:#000080">style</span>>
|
|
.<span style="color:#458;font-weight:bold">hljs-ln-numbers</span> {
|
|
<span style="color:#000;font-weight:bold">display</span>: <span style="color:#000;font-weight:bold">none</span>;
|
|
}
|
|
</<span style="color:#000080">style</span>></code></pre></div>
|
|
</section><section>
|
|
<p>💡 Put the custom CSS in either of these partials:</p>
|
|
<pre><code class="language-text"># for all presentations
|
|
layouts/partials/reveal-hugo/body.html
|
|
</code></pre>
|
|
<pre><code class="language-text"># for one presentation
|
|
layouts/partials/{presentation-name}/reveal-hugo/body.html
|
|
</code></pre>
|
|
</section><section>
|
|
<p>Thanks!</p>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<script type="text/javascript" src=./reveal-hugo/object-assign.js></script>
|
|
|
|
<a href="./reveal-js/css/print/" id="print-location" style="display: none;"></a>
|
|
<script type="text/javascript">
|
|
var printLocationElement = document.getElementById('print-location');
|
|
var link = document.createElement('link');
|
|
link.rel = 'stylesheet';
|
|
link.type = 'text/css';
|
|
link.href = printLocationElement.href + (window.location.search.match(/print-pdf/gi) ? 'pdf.css' : 'paper.css');
|
|
document.getElementsByTagName('head')[0].appendChild(link);
|
|
</script>
|
|
|
|
<script type="application/json" id="reveal-hugo-site-params">{"history":true,"templates":{"grey":{"background":"#424242","transition":"convex"}}}</script>
|
|
<script type="application/json" id="reveal-hugo-page-params">{"highlight_theme":"vs","theme":"white"}</script>
|
|
|
|
<script src="./reveal-js/js/reveal.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
function camelize(map) {
|
|
if (map) {
|
|
Object.keys(map).forEach(function(k) {
|
|
newK = k.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase() });
|
|
if (newK != k) {
|
|
map[newK] = map[k];
|
|
delete map[k];
|
|
}
|
|
});
|
|
}
|
|
return map;
|
|
}
|
|
|
|
var revealHugoDefaults = { center: true, controls: true, history: true, progress: true, transition: "slide" };
|
|
var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML);
|
|
var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML);
|
|
|
|
var options = Object.assign({},
|
|
camelize(revealHugoDefaults),
|
|
camelize(revealHugoSiteParams),
|
|
camelize(revealHugoPageParams));
|
|
Reveal.initialize(options);
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="./reveal-js/plugin/markdown/marked.js"></script>
|
|
|
|
<script type="text/javascript" src="./reveal-js/plugin/markdown/markdown.js"></script>
|
|
|
|
<script type="text/javascript" src="./reveal-js/plugin/highlight/highlight.js"></script>
|
|
|
|
<script type="text/javascript" src="./reveal-js/plugin/zoom-js/zoom.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="./reveal-js/plugin/notes/notes.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
.hljs-ln-numbers {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</body>
|
|
</html>
|