Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data-noescape to highlightjs callouts #167

Merged
merged 7 commits into from
Dec 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
This document provides a high-level view of the changes introduced in {project-name} by release.
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.

== Master branch

Enhancements::
* Documentation improvements ({uri-issue}165[#165])

////
=== Release meta

{uri-repo}/releases/tag/v1.1.0[git tag] |
{uri-repo}/compare/v1.0.4...v1.1.0[full diff]
////


== 1.1.0 (2017-12-25) - @obilodeau

Enhancements::
Expand Down
11 changes: 10 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ To override that behavior use the `width` and `height` named attributes.

=== Syntax highlighting

To enable https://highlightjs.org/[highlight.js] for syntax highlighting (which is the `revealjs` default):

[source, asciidoc]
----
= Title slide
:source-highlighter: highlightjs
----

With enabled source-highlighter you can write code blocks as usual:

[source, asciidoc]
....
== Slide Five
Expand All @@ -395,7 +405,6 @@ print "Hello World"
----
....

`revealjs` uses https://highlightjs.org/[highlight.js] to do its syntax highlighting by default.
By default `[source]` blocks and blocks delimited by `----` will be highlighted.
An explicit `[listing]` block will not be highlighted.
`highlight.js` does language auto-detection but using the `language="..."` attribute will hint the highlighter.
Expand Down
3 changes: 1 addition & 2 deletions examples/source-callouts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ Me

== Callout

// FIXME source callouts are broken right now
[source, rust]
----
fn main() {
println!("Hello World!"); // <1>
}
}
----
<1> `println!` is a macro.
6 changes: 4 additions & 2 deletions templates/listing.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- code_class = language ? [language, "language-#{language}"] : nil
- pre_class = ['highlight']
- pre_lang = nil
- code_noescape = false
- case attr 'source-highlighter'
- when 'coderay'
- pre_class = ['CodeRay']
Expand All @@ -25,9 +26,10 @@
- pre_lang = language
- pre_class = code_class = nil
- nowrap = false
/- when 'highlightjs', 'highlight.js'
- when 'highlightjs', 'highlight.js'
- code_noescape=true
- pre_class << 'nowrap' if nowrap
pre class=pre_class lang=pre_lang
code class=code_class =content
code data-noescape=code_noescape class=code_class =content
- else
pre class=(nowrap ? 'nowrap' : nil) =content
4 changes: 2 additions & 2 deletions test/doctest/source-callouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ <h1>Presentation</h1>
<h2>Callout</h2>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="rust language-rust">fn main() {
<pre class="highlight"><code class="rust language-rust" data-noescape="">fn main() {
println!("Hello World!"); <i class="conum" data-value="1"></i><b>(1)</b>
}</code></pre>
}</code></pre>
</div>
</div>
<div class="colist arabic">
Expand Down