| author | wenzelm | 
| Tue, 09 Apr 2013 13:20:09 +0200 | |
| changeset 51655 | 28d6eb23522c | 
| parent 50238 | 98d35a7368bd | 
| child 53167 | 4e7ddd76e632 | 
| permissions | -rw-r--r-- | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 1 | (* Title: Pure/Thy/latex.ML | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 2 | Author: Markus Wenzel, TU Muenchen | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 3 | |
| 15801 | 4 | LaTeX presentation elements -- based on outer lexical syntax. | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 5 | *) | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 6 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 7 | signature LATEX = | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 8 | sig | 
| 14924 | 9 | val output_known_symbols: (string -> bool) * (string -> bool) -> | 
| 10 | Symbol.symbol list -> string | |
| 11719 | 11 | val output_symbols: Symbol.symbol list -> string | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 12 | val output_basic: Token.T -> string | 
| 17081 | 13 | val output_markup: string -> string -> string | 
| 14 | val output_markup_env: string -> string -> string | |
| 15 | val output_verbatim: string -> string | |
| 16 | val markup_true: string | |
| 17 | val markup_false: string | |
| 18 | val begin_delim: string -> string | |
| 19 | val end_delim: string -> string | |
| 20 | val begin_tag: string -> string | |
| 21 | val end_tag: string -> string | |
| 9707 | 22 | val tex_trailer: string | 
| 9916 | 23 | val isabelle_file: string -> string -> string | 
| 14924 | 24 | val symbol_source: (string -> bool) * (string -> bool) -> | 
| 25 | string -> Symbol.symbol list -> string | |
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 26 | val theory_entry: string -> string | 
| 9135 | 27 | val modes: string list | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 28 | end; | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 29 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 30 | structure Latex: LATEX = | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 31 | struct | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 32 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 33 | (* symbol output *) | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 34 | |
| 7900 | 35 | local | 
| 36 | ||
| 40402 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 37 | val char_table = | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 38 | Symtab.make | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 39 |    [("!", "{\\isacharbang}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 40 |     ("\"", "{\\isachardoublequote}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 41 |     ("#", "{\\isacharhash}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 42 |     ("$", "{\\isachardollar}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 43 |     ("%", "{\\isacharpercent}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 44 |     ("&", "{\\isacharampersand}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 45 |     ("'", "{\\isacharprime}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 46 |     ("(", "{\\isacharparenleft}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 47 |     (")", "{\\isacharparenright}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 48 |     ("*", "{\\isacharasterisk}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 49 |     ("+", "{\\isacharplus}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 50 |     (",", "{\\isacharcomma}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 51 |     ("-", "{\\isacharminus}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 52 |     (".", "{\\isachardot}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 53 |     ("/", "{\\isacharslash}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 54 |     (":", "{\\isacharcolon}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 55 |     (";", "{\\isacharsemicolon}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 56 |     ("<", "{\\isacharless}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 57 |     ("=", "{\\isacharequal}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 58 |     (">", "{\\isachargreater}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 59 |     ("?", "{\\isacharquery}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 60 |     ("@", "{\\isacharat}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 61 |     ("[", "{\\isacharbrackleft}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 62 |     ("\\", "{\\isacharbackslash}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 63 |     ("]", "{\\isacharbrackright}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 64 |     ("^", "{\\isacharcircum}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 65 |     ("_", "{\\isacharunderscore}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 66 |     ("`", "{\\isacharbackquote}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 67 |     ("{", "{\\isacharbraceleft}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 68 |     ("|", "{\\isacharbar}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 69 |     ("}", "{\\isacharbraceright}"),
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 70 |     ("~", "{\\isachartilde}")];
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 71 | |
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 72 | fun output_chr " " = "\\ " | 
| 43709 
717e96cf9527
discontinued special treatment of hard tabulators;
 wenzelm parents: 
43485diff
changeset | 73 | | output_chr "\t" = "\\ " | 
| 40402 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 74 | | output_chr "\n" = "\\isanewline\n" | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 75 | | output_chr c = | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 76 | (case Symtab.lookup char_table c of | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 77 | SOME s => s | 
| 40402 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 78 |       | NONE => if Symbol.is_ascii_digit c then enclose "{\\isadigit{" "}}" c else c);
 | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 79 | |
| 14924 | 80 | val output_chrs = translate_string output_chr; | 
| 81 | ||
| 82 | fun output_known_sym (known_sym, known_ctrl) sym = | |
| 14874 | 83 | (case Symbol.decode sym of | 
| 84 | Symbol.Char s => output_chr s | |
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
36959diff
changeset | 85 | | Symbol.UTF8 s => s | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 86 |   | Symbol.Sym s => if known_sym s then enclose "{\\isasym" "}" s else output_chrs sym
 | 
| 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 87 | | Symbol.Ctrl s => if known_ctrl s then enclose "\\isactrl" " " s else output_chrs sym | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40402diff
changeset | 88 | | Symbol.Raw s => s | 
| 43485 | 89 | | Symbol.Malformed s => error (Symbol.malformed_msg s) | 
| 90 | | Symbol.EOF => error "Bad EOF symbol"); | |
| 7900 | 91 | |
| 92 | in | |
| 93 | ||
| 14924 | 94 | val output_known_symbols = implode oo (map o output_known_sym); | 
| 95 | val output_symbols = output_known_symbols (K true, K true); | |
| 8192 | 96 | val output_syms = output_symbols o Symbol.explode; | 
| 7900 | 97 | |
| 27874 
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
 wenzelm parents: 
27809diff
changeset | 98 | val output_syms_antiq = | 
| 30589 | 99 | (fn Antiquote.Text ss => output_symbols (map Symbol_Pos.symbol ss) | 
| 27874 
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
 wenzelm parents: 
27809diff
changeset | 100 | | Antiquote.Antiq (ss, _) => | 
| 40402 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 101 |         enclose "%\n\\isaantiq\n" "{}%\n\\endisaantiq\n"
 | 
| 
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
 wenzelm parents: 
39666diff
changeset | 102 | (output_symbols (map Symbol_Pos.symbol ss)) | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 103 |     | Antiquote.Open _ => "{\\isaantiqopen}"
 | 
| 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 104 |     | Antiquote.Close _ => "{\\isaantiqclose}");
 | 
| 22648 
8c6b4f7548e3
output_basic: added isaantiq markup (only inside verbatim tokens);
 wenzelm parents: 
19265diff
changeset | 105 | |
| 7900 | 106 | end; | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 107 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 108 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 109 | (* token output *) | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 110 | |
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 111 | val invisible_token = Token.keyword_with (fn s => s = ";") orf Token.is_kind Token.Comment; | 
| 7756 | 112 | |
| 17081 | 113 | fun output_basic tok = | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 114 | let val s = Token.content_of tok in | 
| 17081 | 115 | if invisible_token tok then "" | 
| 46811 
03a2dc9e0624
clarified command span: include trailing whitespace/comments and thus reduce number of ignored spans with associated transactions and states (factor 2);
 wenzelm parents: 
45666diff
changeset | 116 | else if Token.is_command tok then | 
| 17081 | 117 |       "\\isacommand{" ^ output_syms s ^ "}"
 | 
| 50238 
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
 wenzelm parents: 
50201diff
changeset | 118 | else if Token.is_kind Token.Keyword tok andalso Symbol.is_ascii_identifier s then | 
| 17081 | 119 |       "\\isakeyword{" ^ output_syms s ^ "}"
 | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 120 | else if Token.is_kind Token.String tok then | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 121 |       enclose "{\\isachardoublequoteopen}" "{\\isachardoublequoteclose}" (output_syms s)
 | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 122 | else if Token.is_kind Token.AltString tok then | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 123 |       enclose "{\\isacharbackquoteopen}" "{\\isacharbackquoteclose}" (output_syms s)
 | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 124 | else if Token.is_kind Token.Verbatim tok then | 
| 27874 
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
 wenzelm parents: 
27809diff
changeset | 125 | let | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
30642diff
changeset | 126 | val (txt, pos) = Token.source_position_of tok; | 
| 30642 | 127 | val ants = Antiquote.read (Symbol_Pos.explode (txt, pos), pos); | 
| 27874 
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
 wenzelm parents: 
27809diff
changeset | 128 | val out = implode (map output_syms_antiq ants); | 
| 49320 
94bd2fb83d11
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
 wenzelm parents: 
48628diff
changeset | 129 |       in enclose "{\\isacharverbatimopen}" "{\\isacharverbatimclose}" out end
 | 
| 17081 | 130 | else output_syms s | 
| 131 | end; | |
| 132 | ||
| 133 | fun output_markup cmd txt = "%\n\\isamarkup" ^ cmd ^ "{" ^ Symbol.strip_blanks txt ^ "%\n}\n";
 | |
| 7745 | 134 | |
| 17081 | 135 | fun output_markup_env cmd txt = | 
| 136 |   "%\n\\begin{isamarkup" ^ cmd ^ "}%\n" ^
 | |
| 137 | Symbol.strip_blanks txt ^ | |
| 138 |   "%\n\\end{isamarkup" ^ cmd ^ "}%\n";
 | |
| 7756 | 139 | |
| 17081 | 140 | fun output_verbatim txt = "%\n" ^ Symbol.strip_blanks txt ^ "\n"; | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 141 | |
| 17081 | 142 | val markup_true = "\\isamarkuptrue%\n"; | 
| 143 | val markup_false = "\\isamarkupfalse%\n"; | |
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 144 | |
| 17081 | 145 | val begin_delim = enclose "%\n\\isadelim" "\n"; | 
| 146 | val end_delim = enclose "%\n\\endisadelim" "\n"; | |
| 147 | val begin_tag = enclose "%\n\\isatag" "\n"; | |
| 148 | fun end_tag tg = enclose "%\n\\endisatag" "\n" tg ^ enclose "{\\isafold" "}%\n" tg;
 | |
| 11860 | 149 | |
| 150 | ||
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 151 | (* theory presentation *) | 
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 152 | |
| 9707 | 153 | val tex_trailer = | 
| 154 | "%%% Local Variables:\n\ | |
| 9135 | 155 | \%%% mode: latex\n\ | 
| 156 | \%%% TeX-master: \"root\"\n\ | |
| 9144 | 157 | \%%% End:\n"; | 
| 8192 | 158 | |
| 9916 | 159 | fun isabelle_file name txt = | 
| 160 |   "%\n\\begin{isabellebody}%\n\
 | |
| 10247 | 161 |   \\\def\\isabellecontext{" ^ output_syms name ^ "}%\n" ^ txt ^
 | 
| 9916 | 162 |   "\\end{isabellebody}%\n" ^ tex_trailer;
 | 
| 9707 | 163 | |
| 14924 | 164 | fun symbol_source known name syms = isabelle_file name | 
| 165 |   ("\\isamarkupheader{" ^ output_known_symbols known (Symbol.explode name) ^ "}%\n" ^
 | |
| 166 | output_known_symbols known syms); | |
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 167 | |
| 9038 
63d20536971f
session.tex: nsert blank lines in order to guarantee new paragraphs
 wenzelm parents: 
8965diff
changeset | 168 | fun theory_entry name = "\\input{" ^ name ^ ".tex}\n\n";
 | 
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 169 | |
| 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 170 | |
| 8460 | 171 | (* print mode *) | 
| 172 | ||
| 8965 | 173 | val latexN = "latex"; | 
| 17218 | 174 | val modes = [latexN, Symbol.xsymbolsN]; | 
| 8965 | 175 | |
| 8460 | 176 | fun latex_output str = | 
| 177 | let val syms = Symbol.explode str | |
| 23621 | 178 | in (output_symbols syms, Symbol.length syms) end; | 
| 19265 | 179 | |
| 23621 | 180 | fun latex_markup (s, _) = | 
| 50201 
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
 wenzelm parents: 
49554diff
changeset | 181 | if s = Markup.commandN orelse s = Markup.keyword1N | 
| 49554 
7b7bd2d7661d
more explicit keyword1/keyword2 markup -- avoid potential conflict with input token markup produced by Token_Marker;
 wenzelm parents: 
49320diff
changeset | 182 |     then ("\\isacommand{", "}")
 | 
| 50201 
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
 wenzelm parents: 
49554diff
changeset | 183 | else if s = Markup.keywordN orelse s = Markup.keyword2N | 
| 49554 
7b7bd2d7661d
more explicit keyword1/keyword2 markup -- avoid potential conflict with input token markup produced by Token_Marker;
 wenzelm parents: 
49320diff
changeset | 184 |     then ("\\isakeyword{", "}")
 | 
| 29325 | 185 | else Markup.no_output; | 
| 10955 | 186 | |
| 23621 | 187 | fun latex_indent "" _ = "" | 
| 188 |   | latex_indent s _ = enclose "\\isaindent{" "}" s;
 | |
| 189 | ||
| 190 | val _ = Output.add_mode latexN latex_output Symbol.encode_raw; | |
| 23703 | 191 | val _ = Markup.add_mode latexN latex_markup; | 
| 192 | val _ = Pretty.add_mode latexN latex_indent; | |
| 8460 | 193 | |
| 7726 
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
 wenzelm parents: diff
changeset | 194 | end; |