www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 8adf024459cc239121f18a24bf61b9a1722f26ec
parent 0344b94bfd882486a134bb091026167f4e5266c3
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Wed, 12 Jul 2017 16:30:08 +0200

Improved math rendering (reset font size as MathJax seems to have issues with font-size: 15px from scribble's stylesheet.

Diffstat:
Mscribblings/util.rkt | 11+++++------
Mscribblings/util0.rkt | 18+++++++++++++-----
2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/scribblings/util.rkt b/scribblings/util.rkt @@ -577,14 +577,13 @@ EOCSS (quasitemplate (#,(if ((or/c 'expression list?) (syntax-local-context)) #'list #'begin) (define (vcenter lst) - @cond-element[[html (list "\\vcenter{" lst "}")] - [else (list "\\begin{array}{l}" lst "\\end{array}")]]) + (list "\\begin{array}{l}" + (add-between (for/list ([e lst]) (list "\\!" e "\\!")) "\\\\") + "\\end{array}")) (define phantom - @$${\hphantom{@vcenter{@(list (?@ acaseᵢ₀ "\\\\" - (?@ acaseᵢⱼ "\\\\") ...) + @$${\hphantom{@vcenter{@(list (?@ acaseᵢ₀ acaseᵢⱼ ...) ... - (?? (?@ acaseₙ₀ - (?@ acaseₙⱼ "\\\\") ...)))}}}) + (?? (?@ acaseₙ₀ acaseₙⱼ ...)))}}}) (define tmpᵢ @cases[term (?? (?@ #:first-sep first-sep)) (?? (?@ #:then-sep then-sep)) diff --git a/scribblings/util0.rkt b/scribblings/util0.rkt @@ -3,6 +3,7 @@ (require scribble/manual scribble/core scribble/latex-properties + scribble/html-properties scribble-math scribble-math/katex-convert-unicode) @@ -25,16 +26,17 @@ (traverse-element (λ (a b) (clean-$ ((traverse-element-traverse e) a b))))] [(match e - [(element (style (or "math" "texMathInline" "texMathDisplay") - _) + [(element (style (or "math" "texMathInline" "texMathDisplay") _) content) #t] [_ #f]) ;; No need to go down recursively, as the contents should already have ;; been cleaned when the e was created. Plus we risk re-escaping ;; things within \text{…}. - #;(clean-$ (element-content e)) (element-content e)] + [(match e [(element (style "mathWrapper" _) _) #t] + [_ #f]) + (clean-$ (element-content e))] [(match e [(element (style "mathText" _) content) @@ -54,8 +56,14 @@ (katex-convert-unicode e)] [else e])) +(define (math-wrapper $m) + (element (style "mathWrapper" + (list (tex-addition #"\\def\\mathWrapper#1{#1}") + (css-addition #".mathWrapper { font-size: medium; }"))) + $m)) + (define ($* . elts) - (apply $ (clean-$ elts))) + (math-wrapper (apply $ (clean-$ elts)))) (define ($$* . elts) - (apply $$ (clean-$ elts))) + (math-wrapper (apply $$ (clean-$ elts))))