mathjax-convert-unicode, shortened javascript which loads MathJax so that it is easier to compare for removal (since we unfortunately cannot set its ID).

This commit is contained in:
Georges Dupéron 2017-07-21 02:47:46 +02:00
parent fbb7f162a0
commit d4e21dff28
3 changed files with 116 additions and 93 deletions

View File

@ -8,6 +8,7 @@
racket/runtime-path racket/runtime-path
setup/collects setup/collects
"katex-convert-unicode.rkt" "katex-convert-unicode.rkt"
"mathjax-convert-unicode.rkt"
racket/list) racket/list)
(provide $ (provide $
@ -114,13 +115,11 @@ EOJS
(define (load-style-string src) (define (load-style-string src)
(string-append (string-append
#<<EOJS #<<EOJS
(function() { (function() {document.write('<link rel="stylesheet" href="
document.write('<link rel="stylesheet" href="
EOJS EOJS
src src
#<<EOJS #<<EOJS
" />'); " />');})();
})();
EOJS EOJS
)) ))

View File

@ -1,7 +1,8 @@
#lang at-exp racket/base #lang at-exp racket/base
(require racket/string) (require racket/string)
(provide katex-convert-unicode) (provide katex-convert-unicode
string-replace*)
(define (literal-alternatives→regexp literal-alternatives) (define (literal-alternatives→regexp literal-alternatives)
(string-append "(" (string-append "("
@ -22,11 +23,8 @@
replacement replacement
(string-append "$" replacement "$")))))) (string-append "$" replacement "$"))))))
(define (katex-convert-unicode str mathmode?) (define (katex-convert-unicode str mathmode? [more-sym→* '()])
(if (string? str) (define sym→*
(string-replace*
str
mathmode?
`([ "{}_0"] `([ "{}_0"]
[ "{}_1"] [ "{}_1"]
[ "{}_2"] [ "{}_2"]
@ -114,4 +112,9 @@
[ "\\bigvee{}"] [ "\\bigvee{}"]
[± "\\pm{}"] [± "\\pm{}"]
)) ))
(if (string? str)
(string-replace*
str
mathmode?
(append more-sym→* sym→*))
str)) str))

View File

@ -0,0 +1,21 @@
#lang at-exp racket/base
(require racket/string
scriblib/render-cond
"katex-convert-unicode.rkt")
(provide mathjax-convert-unicode)
(define (mathjax-convert-unicode str* mathmode?)
(define more-sym→*
`([ ,(string-append
"\\ifmathjax{\\mathrel{{\\raise0.9mu{::}\\hspace{-4mu}=}}}"
"\\iflatex{\\Coloneqq}")]
[ "\\in{}"]
[κ "\\kappa"]
[ "{}^+"]
[ "{}^-"]
;; TODO:
[ "\\ifmathjax{\\unicode{x2272}}\\iflatex{}"]
[ "\\ifmathjax{\\unicode{x2273}}\\iflatex{}"]
))
(katex-convert-unicode str* mathmode? more-sym→*))