Skip to content

Commit

Permalink
Add mathmode? option to katex-convert-unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
SuzanneSoy committed Jul 12, 2017
1 parent e1f3c3d commit 4386f65
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions katex-convert-unicode.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(string-join (map regexp-quote literal-alternatives) "|")
")"))

(define (string-replace* str sym→*)
(define (string-replace* str mathmode? sym→*)
(define →* (map (λ (x)
(cons (symbol->string (car x))
(cadr x)))
Expand All @@ -17,12 +17,16 @@
(regexp-replace* (literal-alternatives→regexp (map car →*))
str
(λ (found . _)
(hash-ref hash→* found))))
(let ([replacement (hash-ref hash→* found)])
(if mathmode?
replacement
(string-append "$" replacement "$"))))))

(define (katex-convert-unicode str)
(define (katex-convert-unicode str mathmode?)
(if (string? str)
(string-replace*
str
mathmode?
'([₀ "{}_0"]
[₁ "{}_1"]
[₂ "{}_2"]
Expand Down

0 comments on commit 4386f65

Please sign in to comment.