Skip to content

Commit

Permalink
Add support for math formulas, add -n option, fix example slideshow l…
Browse files Browse the repository at this point in the history
…ink, bump version to 1.2.0
  • Loading branch information
danielgtaylor committed Jan 24, 2017
1 parent 7346643 commit ead7db7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
19 changes: 18 additions & 1 deletion data/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is an example. Press <kbd>&#8680;</kbd> 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)

---

Expand Down Expand Up @@ -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**
<!-- Notice that we escape the `*` because it has special meaning in Markdown -->
%%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.
Expand Down
1 change: 1 addition & 0 deletions data/index.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<a class="btn">Close</a>
</div>
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js"></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML&delayStartupUntil=configured"></script>
<script src="/static/script.js"></script>
</body>
</html>
6 changes: 4 additions & 2 deletions tech-talk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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()
}
Expand Down
11 changes: 11 additions & 0 deletions www/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit ead7db7

Please sign in to comment.