simplify MathJax interface

pull/58/head
Matthew Butterick 10 years ago
parent ace1681b9c
commit 725447ec21

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require pollen/convert) (require pollen/convert)
(provide $ $$) (provide $ $$ mathjax-config mathjax-library)
(define mathjax-config #<<HTML (define mathjax-config #<<HTML
<script type="text/x-mathjax-config"> <script type="text/x-mathjax-config">
@ -17,18 +17,11 @@ HTML
HTML HTML
) )
(define first-run #t)
(define (mathjax-wrapper #:delimiter delimiter xs) (define (mathjax-wrapper #:delimiter delimiter xs)
`(mathjax `(mathjax ,(apply string-append `(,delimiter ,@xs ,delimiter))))
,@(if first-run ; only need mathjax-config & mathjax-library once on the page
(begin (set! first-run #f) (map html->xexpr (list mathjax-config mathjax-library)))
null)
,(apply string-append `(,delimiter ,@xs ,delimiter))))
(define ($ . x) (define ($ . x)
(mathjax-wrapper #:delimiter "$" x)) (mathjax-wrapper #:delimiter "$" x))
(define ($$ . x) (define ($$ . x)
(mathjax-wrapper #:delimiter "$$" x)) (mathjax-wrapper #:delimiter "$$" x))

Loading…
Cancel
Save