Skip to content

Commit

Permalink
resolves #21 load highlight.js from a CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Feb 8, 2020
1 parent 3ee563f commit 8e0d346
Show file tree
Hide file tree
Showing 19 changed files with 882 additions and 19 deletions.
1 change: 1 addition & 0 deletions HACKING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ Then run:
== Release process


. Make sure that the highlight plugin code embed in _lib/asciidoctor-revealjs/highlightjs.rb_ is up-to-date with the version of reveal.js
. Do we need to do anything regarding our Opal dependency and Asciidoctor.js?
See <<node-binary-compatibility,our section on the topic>>.
. Update dependencies and test the package in both languages
Expand Down
28 changes: 24 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ To override that behavior use the `width` and `height` named attributes.

=== Syntax highlighting

Reveal.js is well integrated with https://highlightjs.org/[highlight.js] for syntax highlighting.
reveal.js is well integrated with https://highlightjs.org/[Highlight.js] for syntax highlighting.
Asciidoctor reveal.js supports that.
You can activate highlight.js syntax highlighting (disabled by default) by setting the `source-highlighter` document attribute as follows:
You can activate Highlight.js syntax highlighting (disabled by default) by setting the `source-highlighter` document attribute as follows:

[source, asciidoc]
----
Expand All @@ -541,7 +541,26 @@ You can activate highlight.js syntax highlighting (disabled by default) by setti
:source-highlighter: highlightjs
----

Once enabled you can write code blocks as usual:
[NOTE]
----
By default, we are using a prebuilt version of Highlight.js with 34 commonly used languages hosted on https://cdnjs.com/[cdnjs].
You can load additionnal languages using the `:highlightjs-languages:` attribute:
```
// load yaml and scilab languages
:highlightjs-languages: yaml, scilab
```
You can also load Highlight.js from a custom base directory (or remote URL) using the `:highlightjsdir:` attribute:
```
// load from a local path
:highlightjsdir: highlight
// load from jsdelivr CDN
//:highlightjsdir: https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.0/build
----

Once enabled, you can write code blocks as usual:

[source, asciidoc]
....
Expand Down Expand Up @@ -571,7 +590,8 @@ print "$0: hello world\n"
....

[NOTE]
Alternatively, you can use http://coderay.rubychan.de[Coderay] or http://pygments.org[Pygments] as syntax highlighters if you are using the Asciidoctor/Ruby/Bundler toolchain (not Asciidoctor.js/JavaScript/npm).
Alternatively, you can use http://rouge.jneen.net/[Rouge], http://coderay.rubychan.de[Coderay] or http://pygments.org[Pygments] as syntax highlighters,
if you are using the Asciidoctor/Ruby/Bundler toolchain (not Asciidoctor.js/JavaScript/npm).
Check the `examples/` directory for examples and notes about what needs to be done for them to work.
They are considered unsupported by the asciidoctor-reveal.js project.

Expand Down
2 changes: 1 addition & 1 deletion examples/source-highlightjs-html.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Avoiding regressions with HTML source code inside source block
// :include: //div[@class="slides"]
// :header_footer:
= HTML Source Code with Highlight.JS
= HTML Source Code with Highlight.js
:icons: font
:source-highlighter: highlightjs

Expand Down
27 changes: 27 additions & 0 deletions examples/source-highlightjs-languages.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// .source-highlightjs-languages
// Demonstration of source highlighting with highlight.js using additional languages
// :include: //div[@class="slides"] | //body/script
// :header_footer:
= Scilab Code with Highlight.js: using additional languages
:source-highlighter: highlight.js
:highlightjs-languages: yaml, scilab

== Use the Source

[source,scilab]
----
function B=gauss_filter_3_3(A)
x=size(A,2);
y=size(A,1);
B = zeros(y, x);
for j = 2:y-1
for i= 2:x-1
val= 4*A(j,i)+2*(A(j,i-1)+A(j,i+1)+A(j+1,i)+A(j-1,i))+A(j+1,i+1)+A(j-1,i+1)+A(j+1,i-1)+A(j-1,i-1);
B(j,i) = val/16;
end
end
endfunction
A = rand(10, 10) * 256;
B = gauss_filter_3_3(A);
----
4 changes: 2 additions & 2 deletions examples/source-highlightjs.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// .source-highlightjs
// Demonstration of source highlighting with highlightjs
// Demonstration of source highlighting with highlight.js
// :include: //div[@class="slides"]
// :header_footer:
= Source Code with Highlight.JS
= Source Code with Highlight.js
:icons: font
:source-highlighter: highlightjs

Expand Down
Loading

0 comments on commit 8e0d346

Please sign in to comment.