From ead7db76c0931975a847be8985ba69ec462df2b3 Mon Sep 17 00:00:00 2001 From: "Daniel G. Taylor" Date: Tue, 24 Jan 2017 09:26:33 -0800 Subject: [PATCH] Add support for math formulas, add -n option, fix example slideshow link, bump version to 1.2.0 --- README.md | 1 + data/example.md | 19 ++++++++++++++++++- data/index.template | 1 + tech-talk.go | 6 ++++-- www/script.js | 11 +++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ecd8dc..4f6d4e6 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Now, make your customizations! - [Javascript (transitions)](https://github.com/danielgtaylor/tech-talk/tree/master/www/script.js) - [Terminal default font size](https://github.com/danielgtaylor/tech-talk/tree/master/www/wetty/wetty.js) - [Example slideshow](https://github.com/danielgtaylor/tech-talk/tree/master/data/example.md) +- [HTML template](https://github.com/danielgtaylor/tech-talk/blob/master/data/index.template) Once you are ready: diff --git a/data/example.md b/data/example.md index 2a64884..348f966 100644 --- a/data/example.md +++ b/data/example.md @@ -2,7 +2,7 @@ This is an example. Press to continue. -[View example source](https://github.com/danielgtaylor/tech-talk/data/example.md) +[View example source](https://github.com/danielgtaylor/tech-talk/blob/master/data/example.md) --- @@ -57,6 +57,23 @@ But you aren't limited to just list items. --- +# Math & Formulas + +Complex formulas are easy to display with [AsciiMath](http://asciimath.org/#syntax) using `%%`, or Tex / LaTeX using `$$` delimiters thanks to MathJax. + +.center[ +**AsciiMath example** + +%%i = sum(1.65 \* 0.000125^(o - 1) \* (1 - 2.718^(-0.04t) / 4.15) \* (7490duz) / (100h))%% +] + +.center[ +**LaTeX example** +$$ax^2 + bx + c = 0$$ +] + +--- + # Images & Videos Assets in the same folder as the Markdown slides can be referenced relative to the root of the server. diff --git a/data/index.template b/data/index.template index b5e2324..21bca1d 100644 --- a/data/index.template +++ b/data/index.template @@ -17,6 +17,7 @@ Close + diff --git a/tech-talk.go b/tech-talk.go index 263ca26..f078038 100644 --- a/tech-talk.go +++ b/tech-talk.go @@ -25,7 +25,7 @@ type TemplateValues struct { } const DEFAULT_HOST = "localhost" -const VERSION = "1.1.0" +const VERSION = "1.2.0" var indexTemplate *template.Template var socketServer *socketio.Server @@ -36,6 +36,7 @@ var sshType *string var sshHost *string var key *string var pass *string +var noBrowser *bool // Checks if a file exists and can be accessed. func check_access(filename string) bool { @@ -144,6 +145,7 @@ func main() { pass = flag.String("pass", "", "SSH `password` (for internal SSH)") // Misc options + noBrowser = flag.Bool("n", false, "Do not automatically open browser") version := flag.Bool("v", false, "Alias for --version") flag.BoolVar(version, "version", false, "Print program version and exit") @@ -187,7 +189,7 @@ func main() { log.Println("Server started on http://localhost:4000/") - if check_access("/usr/bin/open") { + if !*noBrowser && check_access("/usr/bin/open") { c := exec.Command("/usr/bin/open", "http://localhost:4000") c.Start() } diff --git a/www/script.js b/www/script.js index f6e1777..a1fa87e 100644 --- a/www/script.js +++ b/www/script.js @@ -102,3 +102,14 @@ window.addEventListener('load', () => { document.body.classList.remove('preload'); }, 200); }); + +// Setup MathJax +MathJax.Hub.Config({ + asciimath2jax: { + // Since Markdown makes heavy use of backticks, prefer a syntax that + // won't conflict with Markdown processing. + delimiters: [['%%','%%']] + } +}); + +MathJax.Hub.Configured();