forked from joshed-io/reveal-hugo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request joshed-io#138 from deining/math-code-blocks
Support for math code blocks (incl. auto activation of MathJax)
- Loading branch information
Showing
9 changed files
with
159 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
+++ | ||
weight = 21 | ||
+++ | ||
{{< slide id=configuration >}} | ||
|
||
# Configuration | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
+++ | ||
weight = 31 | ||
+++ | ||
|
||
{{< slide id=math-shortcode >}} | ||
|
||
### Mathematical equations | ||
|
||
Use the `math` shortcode if you need to enable reveal-js highlighting module | ||
(`codeFences = false`). | ||
|
||
```code | ||
{{</* math */>}} | ||
\tag*{(1)} \lim\limits_{x \to \infty} \exp(-x) = 0 | ||
{{</* /math */>}} | ||
``` | ||
<small> | ||
displays as: | ||
</small> | ||
|
||
{{< math >}} | ||
\tag*{(1)} \lim\limits_{x \to \infty} \exp(-x) = 0 | ||
{{< /math >}} | ||
|
||
For inline equations, use a self closed `math` shortcode: | ||
|
||
```code | ||
Albert Einstein's famous formula: {{</* math "E=mc^2" /*/>}} | ||
``` | ||
<small> | ||
is rendered to: | ||
</small> | ||
|
||
Albert Einstein's famous formula: {{< math "E=mc^2" />}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p>$${{- .Inner | safeHTML }}$$</p> | ||
{{ .Page.Store.Set "hasMath" true -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{{ $math := "" -}} | ||
|
||
{{ with .Get "inline" -}} | ||
{{/* Error checking */ -}} | ||
{{ if $.Inner -}} | ||
{{ errorf "%s: shortcode math with parameter 'inline' must not have inner content declared" $.Page.File.Path -}} | ||
{{ end -}} | ||
{{ if ne ( printf "%T" . ) "string" -}} | ||
{{ errorf "%s: shortcode math: parameter 'inline' must be a string" $.Page.File.Path -}} | ||
{{ end -}} | ||
{{ $math = . -}} | ||
{{ else -}} | ||
{{ with $.Get 0 -}} | ||
{{ if $.Inner -}} | ||
{{ errorf "%s: shortcode math for inline content must not have inner content declared" $.Page.File.Path -}} | ||
{{ end -}} | ||
{{ $math = $.Get 0 -}} | ||
{{ else }} | ||
{{ if .IsNamedParams}} | ||
{{ errorf "%s: shortcode math: Invalid named parameter(s) (%v) detected. Only named parameter 'inline' is allowed." $.Page.File.Path .Params -}} | ||
{{ end }} | ||
{{ end -}} | ||
{{ end -}} | ||
|
||
{{ if eq $math "" -}} | ||
<p>$${{- .Inner | safeHTML }}$$</p> | ||
{{ else -}} | ||
${{- $math | safeHTML }}$ | ||
{{ end -}} | ||
|
||
{{ .Page.Store.Set "hasMath" true }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters