#lang racket/base (require scribble/manual scribble/core scribble/html-properties scribble/latex-properties scriblib/render-cond racket/runtime-path setup/collects) (provide $ $$ $-html-handler $$-html-handler $-katex $$-katex $-mathjax $$-mathjax use-katex use-mathjax with-html5) ;; KaTeX does not work well with the HTML 4.01 Transitional loose DTD, ;; so we define a style modifier which replaces the prefix for HTML rendering. (define (with-html5 doc-style) (define has-html-defaults? (memf html-defaults? (style-properties doc-style))) (define new-properties (if has-html-defaults? (map (λ (s) (if (html-defaults? s) (html-defaults (path->collects-relative (collection-file-path "html5-prefix.html" "scribble-math")) (html-defaults-style-path s) (html-defaults-extra-files s)) s)) (style-properties doc-style)) (cons (html-defaults (path->collects-relative (collection-file-path "html5-prefix.html" "scribble-math")) #f '())))) (style (style-name doc-style) new-properties)) (define-runtime-path mathjax-dir "MathJax") (define-runtime-path katex-dir "katex") #| (define mathjax-dir (path->collects-relative (collection-file-path "MathJax" "scribble-math"))) |# (define (load-script-string src) (string-append #<'); })(); eojs )) (define (load-style-string src) (string-append #<'); })(); eojs )) (define load-mathjax-code (string->bytes/utf-8 (load-script-string "MathJax/MathJax.js?config=default"))) (define load-katex-code+style (string->bytes/utf-8 (string-append (load-style-string "katex/katex.min.css") (load-script-string "katex/katex.min.js") #<