Scribble Latex: more complete and consistent handling of accented letters
original commit: 6a82c8bb7c2dce32838dd3dbbb68d76930fcb96a
This commit is contained in:
parent
0b1c035661
commit
d5a9bdadb8
|
@ -753,8 +753,8 @@
|
||||||
(let ([len (string-length s)])
|
(let ([len (string-length s)])
|
||||||
(let loop ([i 0])
|
(let loop ([i 0])
|
||||||
(unless (= i len)
|
(unless (= i len)
|
||||||
(let ([c (string-ref s i)])
|
(display
|
||||||
(display
|
(let char-loop ([c (string-ref s i)])
|
||||||
(case c
|
(case c
|
||||||
[(#\\) (if (rendering-tt)
|
[(#\\) (if (rendering-tt)
|
||||||
"{\\char`\\\\}"
|
"{\\char`\\\\}"
|
||||||
|
@ -942,52 +942,10 @@
|
||||||
[(#\☺) "$\\smiley$"]
|
[(#\☺) "$\\smiley$"]
|
||||||
[(#\☻) "$\\blacksmiley$"]
|
[(#\☻) "$\\blacksmiley$"]
|
||||||
[(#\☹) "$\\frownie$"]
|
[(#\☹) "$\\frownie$"]
|
||||||
[(#\à) "\\`{a}"]
|
|
||||||
[(#\À) "\\`{A}"]
|
|
||||||
[(#\á) "\\'{a}"]
|
|
||||||
[(#\â) "\\^{a}"]
|
|
||||||
[(#\Â) "\\^{A}"]
|
|
||||||
[(#\Á) "\\'{A}"]
|
|
||||||
[(#\ç) "\\c{c}"]
|
|
||||||
[(#\Ç) "\\c{C}"]
|
|
||||||
[(#\è) "\\`{e}"]
|
|
||||||
[(#\È) "\\`{E}"]
|
|
||||||
[(#\é) "\\'{e}"]
|
|
||||||
[(#\É) "\\'{E}"]
|
|
||||||
[(#\ê) "\\^{e}"]
|
|
||||||
[(#\Ê) "\\^{E}"]
|
|
||||||
[(#\í) "\\'{i}"]
|
|
||||||
[(#\Í) "\\'{I}"]
|
|
||||||
[(#\î) "\\^{i}"]
|
|
||||||
[(#\Î) "\\^{I}"]
|
|
||||||
[(#\ô) "\\^{o}"]
|
|
||||||
[(#\Ô) "\\^{O}"]
|
|
||||||
[(#\û) "\\^{u}"]
|
|
||||||
[(#\Û) "\\^{U}"]
|
|
||||||
[(#\ā) "\\={a}"]
|
|
||||||
[(#\ē) "\\={e}"]
|
|
||||||
[(#\ī) "\\={i}"]
|
|
||||||
[(#\ō) "\\={o}"]
|
|
||||||
[(#\ū) "\\={u}"]
|
|
||||||
[(#\Ā) "\\={A}"]
|
|
||||||
[(#\Ē) "\\={E}"]
|
|
||||||
[(#\Ī) "\\={I}"]
|
|
||||||
[(#\Ō) "\\={O}"]
|
|
||||||
[(#\Ū) "\\={U}"]
|
|
||||||
[(#\ä) "\\\"a"]
|
|
||||||
[(#\Ä) "\\\"A"]
|
|
||||||
[(#\ü) "\\\"u"]
|
|
||||||
[(#\Ü) "\\\"U"]
|
|
||||||
[(#\ö) "\\\"o"]
|
|
||||||
[(#\Ö) "\\\"O"]
|
|
||||||
[(#\ø) "{\\o}"]
|
[(#\ø) "{\\o}"]
|
||||||
[(#\Ø) "{\\O}"]
|
[(#\Ø) "{\\O}"]
|
||||||
[(#\ł) "{\\l}"]
|
[(#\ł) "{\\l}"]
|
||||||
[(#\Ł) "{\\L}"]
|
[(#\Ł) "{\\L}"]
|
||||||
[(#\ř) "{\\v r}"]
|
|
||||||
[(#\Ř) "{\\v R}"]
|
|
||||||
[(#\š) "{\\v s}"]
|
|
||||||
[(#\Š) "{\\v S}"]
|
|
||||||
[(#\uA7) "{\\S}"]
|
[(#\uA7) "{\\S}"]
|
||||||
[(#\〚) "$[\\![$"]
|
[(#\〚) "$[\\![$"]
|
||||||
[(#\〛) "$]\\!]$"]
|
[(#\〛) "$]\\!]$"]
|
||||||
|
@ -1007,7 +965,34 @@
|
||||||
[(#\u2079) "$^9$"]
|
[(#\u2079) "$^9$"]
|
||||||
[(#\u207a) "$^+$"]
|
[(#\u207a) "$^+$"]
|
||||||
[(#\u207b) "$^-$"]
|
[(#\u207b) "$^-$"]
|
||||||
[else c])
|
[else
|
||||||
|
;; Detect characters that can be formed with combining characters
|
||||||
|
;; and translate them to Latex combinations:
|
||||||
|
(define s (string-normalize-nfd (string c)))
|
||||||
|
(define len (string-length s))
|
||||||
|
(cond
|
||||||
|
[(len . > . 1)
|
||||||
|
(define combiner (case (string-ref s (sub1 len))
|
||||||
|
[(#\u300) "\\`{~a}"]
|
||||||
|
[(#\u301) "\\'{~a}"]
|
||||||
|
[(#\u302) "\\^{~a}"]
|
||||||
|
[(#\u303) "\\~~{~a}"]
|
||||||
|
[(#\u304) "\\={~a}"]
|
||||||
|
[(#\u306) "\\u{~a}"]
|
||||||
|
[(#\u307) "\\.{~a}"]
|
||||||
|
[(#\u308) "\\\"{~a}"]
|
||||||
|
[(#\u30a) "\\r{~a}"]
|
||||||
|
[(#\u30b) "\\H{~a}"]
|
||||||
|
[(#\u30c) "\\v{~a}"]
|
||||||
|
[(#\u327) "\\c{~a}"]
|
||||||
|
[(#\u328) "\\k{~a}"]
|
||||||
|
[else #f]))
|
||||||
|
(define base (string-normalize-nfc (substring s 0 (sub1 len))))
|
||||||
|
(if (and combiner
|
||||||
|
(= 1 (string-length base)))
|
||||||
|
(format combiner (char-loop (string-ref base 0)))
|
||||||
|
c)]
|
||||||
|
[else c])])
|
||||||
c)])))
|
c)])))
|
||||||
(loop (add1 i)))))))
|
(loop (add1 i)))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user