Add mathmode? option to katex-convert-unicode
This commit is contained in:
parent
e1f3c3daa6
commit
4386f6563d
|
@ -8,7 +8,7 @@
|
||||||
(string-join (map regexp-quote literal-alternatives) "|")
|
(string-join (map regexp-quote literal-alternatives) "|")
|
||||||
")"))
|
")"))
|
||||||
|
|
||||||
(define (string-replace* str sym→*)
|
(define (string-replace* str mathmode? sym→*)
|
||||||
(define →* (map (λ (x)
|
(define →* (map (λ (x)
|
||||||
(cons (symbol->string (car x))
|
(cons (symbol->string (car x))
|
||||||
(cadr x)))
|
(cadr x)))
|
||||||
|
@ -17,12 +17,16 @@
|
||||||
(regexp-replace* (literal-alternatives→regexp (map car →*))
|
(regexp-replace* (literal-alternatives→regexp (map car →*))
|
||||||
str
|
str
|
||||||
(λ (found . _)
|
(λ (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)
|
(if (string? str)
|
||||||
(string-replace*
|
(string-replace*
|
||||||
str
|
str
|
||||||
|
mathmode?
|
||||||
'([₀ "{}_0"]
|
'([₀ "{}_0"]
|
||||||
[₁ "{}_1"]
|
[₁ "{}_1"]
|
||||||
[₂ "{}_2"]
|
[₂ "{}_2"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user