# HG changeset patch # User wenzelm # Date 1125251295 -7200 # Node ID 18a98ecc682108a279e2cea5a081af344d883cc3 # Parent 53cc9e134f40f8d586b7c6dd9f1ada7deb173a02 output \<^loc> as 'loc' span; tuned; diff -r 53cc9e134f40 -r 18a98ecc6821 src/Pure/Thy/html.ML --- a/src/Pure/Thy/html.ML Sun Aug 28 19:47:24 2005 +0200 +++ b/src/Pure/Thy/html.ML Sun Aug 28 19:48:15 2005 +0200 @@ -54,8 +54,6 @@ (* symbol output *) local - val escape = fn "<" => "<" | ">" => ">" | "&" => "&" | c => c; - val html_syms = Symtab.make [("\\", (2.0, "  ")), ("\\", (1.0, "¡")), @@ -200,40 +198,39 @@ ("\\<^bsub>", (0.0, "")), ("\\<^esub>", (0.0, "")), ("\\<^bsup>", (0.0, "")), - ("\\<^esup>", (0.0, "")), - ("\\<^sub>", (0.0, "\\<^sub>")), - ("\\<^sup>", (0.0, "\\<^sup>")), - ("\\<^isub>", (0.0, "\\<^isub>")), - ("\\<^isup>", (0.0, "\\<^isup>"))]; + ("\\<^esup>", (0.0, ""))]; + + val escape = fn "<" => "<" | ">" => ">" | "&" => "&" | c => c; fun output_sym s = if Symbol.is_raw s then (1.0, Symbol.decode_raw s) else (case Symtab.lookup (html_syms, s) of SOME x => x - | NONE => (real (size s), implode (map escape (explode s)))); + | NONE => (real (size s), translate_string escape s)); - fun add_sym (width, (w: real, s)) = (width + w, s); + fun output_sub s = apsnd (enclose "" "") (output_sym s); + fun output_sup s = apsnd (enclose "" "") (output_sym s); + fun output_loc s = apsnd (enclose "" "") (output_sym s); - fun script (0, "\\<^sub>") = (1, "") - | script (0, "\\<^isub>") = (1, "") - | script (0, "\\<^sup>") = (2, "") - | script (0, "\\<^isup>") = (2, "") - | script (0, x) = (0, x) - | script (1, x) = (0, x ^ "") - | script (2, x) = (0, x ^ ""); - - fun scripts ss = #2 (foldl_map script (0, ss @ [""])); + fun output_syms ("\\<^sub>" :: s :: ss) = output_sub s :: output_syms ss + | output_syms ("\\<^isub>" :: s :: ss) = output_sub s :: output_syms ss + | output_syms ("\\<^sup>" :: s :: ss) = output_sup s :: output_syms ss + | output_syms ("\\<^isup>" :: s :: ss) = output_sup s :: output_syms ss + | output_syms ("\\<^loc>" :: s :: ss) = output_loc s :: output_syms ss + | output_syms (s :: ss) = output_sym s :: output_syms ss + | output_syms [] = []; in fun output_width str = if not (exists_string (equal "\\" orf equal "<" orf equal ">" orf equal "&") str) then Symbol.default_output str else - let val (width, syms) = foldl_map add_sym (0.0, map output_sym (Symbol.explode str)) - in (implode (scripts syms), width) end; + let val (syms, width) = fold_map (fn (w, s) => fn width => (s, w + width)) + (output_syms (Symbol.explode str)) 0.0 + in (implode syms, width) end; val output = #1 o output_width; -val output_symbols = scripts o map (#2 o output_sym); +val output_symbols = map #2 o output_syms; end; @@ -365,7 +362,7 @@ fun verbatim_source ss = "\n\n
\n
\n
" ^
-  implode (output_symbols ss)  ^
+  implode (output_symbols ss) ^
   "
\n
\n
\n
\n";