| author | wenzelm |
| Wed, 02 Feb 2011 15:04:09 +0100 | |
| changeset 41683 | 73dde8006820 |
| parent 40523 | 1050315f6ee2 |
| child 42290 | b1f544c84040 |
| 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:
30642
diff
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 |
|
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
33 |
(* literal text *) |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
34 |
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
35 |
local |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
36 |
val hex = Int.fmt StringCvt.HEX; |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
37 |
fun hex_byte c = hex (ord c div 16) ^ hex (ord c mod 16); |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
38 |
in |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
39 |
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
40 |
fun literal txt = "\\isaliteral{" ^ translate_string hex_byte txt ^ "}";
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
41 |
fun enclose_literal txt arg = enclose "{" "}" (literal txt ^ arg);
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
42 |
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
43 |
end; |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
44 |
|
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
45 |
|
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
46 |
(* symbol output *) |
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
47 |
|
| 7900 | 48 |
local |
49 |
||
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
50 |
val char_table = |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
51 |
Symtab.make |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
52 |
[("!", "{\\isacharbang}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
53 |
("\"", "{\\isachardoublequote}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
54 |
("#", "{\\isacharhash}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
55 |
("$", "{\\isachardollar}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
56 |
("%", "{\\isacharpercent}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
57 |
("&", "{\\isacharampersand}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
58 |
("'", "{\\isacharprime}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
59 |
("(", "{\\isacharparenleft}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
60 |
(")", "{\\isacharparenright}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
61 |
("*", "{\\isacharasterisk}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
62 |
("+", "{\\isacharplus}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
63 |
(",", "{\\isacharcomma}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
64 |
("-", "{\\isacharminus}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
65 |
(".", "{\\isachardot}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
66 |
("/", "{\\isacharslash}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
67 |
(":", "{\\isacharcolon}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
68 |
(";", "{\\isacharsemicolon}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
69 |
("<", "{\\isacharless}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
70 |
("=", "{\\isacharequal}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
71 |
(">", "{\\isachargreater}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
72 |
("?", "{\\isacharquery}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
73 |
("@", "{\\isacharat}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
74 |
("[", "{\\isacharbrackleft}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
75 |
("\\", "{\\isacharbackslash}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
76 |
("]", "{\\isacharbrackright}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
77 |
("^", "{\\isacharcircum}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
78 |
("_", "{\\isacharunderscore}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
79 |
("`", "{\\isacharbackquote}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
80 |
("{", "{\\isacharbraceleft}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
81 |
("|", "{\\isacharbar}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
82 |
("}", "{\\isacharbraceright}"),
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
83 |
("~", "{\\isachartilde}")];
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
84 |
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
85 |
fun output_chr " " = "\\ " |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
86 |
| output_chr "\n" = "\\isanewline\n" |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
87 |
| output_chr c = |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
88 |
(case Symtab.lookup char_table c of |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
89 |
SOME s => enclose_literal c s |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
90 |
| 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
|
91 |
|
| 14924 | 92 |
val output_chrs = translate_string output_chr; |
93 |
||
94 |
fun output_known_sym (known_sym, known_ctrl) sym = |
|
| 14874 | 95 |
(case Symbol.decode sym of |
96 |
Symbol.Char s => output_chr s |
|
|
37533
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
36959
diff
changeset
|
97 |
| Symbol.UTF8 s => s |
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
98 |
| Symbol.Sym s => |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
99 |
if known_sym s then enclose_literal sym (enclose "{\\isasym" "}" s)
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
100 |
else output_chrs sym |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
101 |
| Symbol.Ctrl s => |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
102 |
if known_ctrl s then literal sym ^ "{}" ^ enclose "\\isactrl" " " s
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
103 |
else output_chrs sym |
|
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40402
diff
changeset
|
104 |
| Symbol.Raw s => s |
|
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40402
diff
changeset
|
105 |
| Symbol.Malformed s => error (Symbol.malformed_msg s)); |
| 7900 | 106 |
|
107 |
in |
|
108 |
||
| 14924 | 109 |
val output_known_symbols = implode oo (map o output_known_sym); |
110 |
val output_symbols = output_known_symbols (K true, K true); |
|
| 8192 | 111 |
val output_syms = output_symbols o Symbol.explode; |
| 7900 | 112 |
|
|
27874
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
wenzelm
parents:
27809
diff
changeset
|
113 |
val output_syms_antiq = |
| 30589 | 114 |
(fn Antiquote.Text ss => output_symbols (map Symbol_Pos.symbol ss) |
|
27874
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
wenzelm
parents:
27809
diff
changeset
|
115 |
| Antiquote.Antiq (ss, _) => |
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
116 |
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:
39666
diff
changeset
|
117 |
(output_symbols (map Symbol_Pos.symbol ss)) |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
118 |
| Antiquote.Open _ => enclose_literal "\\<lbrace>" "{\\isaantiqopen}"
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
119 |
| Antiquote.Close _ => enclose_literal "\\<rbrace>" "{\\isaantiqclose}");
|
|
22648
8c6b4f7548e3
output_basic: added isaantiq markup (only inside verbatim tokens);
wenzelm
parents:
19265
diff
changeset
|
120 |
|
| 7900 | 121 |
end; |
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
122 |
|
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
123 |
|
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
124 |
(* token output *) |
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
125 |
|
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
126 |
val invisible_token = Token.keyword_with (fn s => s = ";") orf Token.is_kind Token.Comment; |
| 7756 | 127 |
|
| 17081 | 128 |
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:
30642
diff
changeset
|
129 |
let val s = Token.content_of tok in |
| 17081 | 130 |
if invisible_token tok then "" |
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
131 |
else if Token.is_kind Token.Command tok then |
| 17081 | 132 |
"\\isacommand{" ^ output_syms s ^ "}"
|
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
133 |
else if Token.is_kind Token.Keyword tok andalso Syntax.is_ascii_identifier s then |
| 17081 | 134 |
"\\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:
30642
diff
changeset
|
135 |
else if Token.is_kind Token.String tok then |
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
136 |
output_syms s |> enclose |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
137 |
(enclose_literal "\"" "{\\isachardoublequoteopen}")
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
138 |
(enclose_literal "\"" "{\\isachardoublequoteclose}")
|
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
139 |
else if Token.is_kind Token.AltString tok then |
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
140 |
output_syms s |> enclose |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
141 |
(enclose_literal "`" "{\\isacharbackquoteopen}")
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
142 |
(enclose_literal "`" "{\\isacharbackquoteclose}")
|
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
143 |
else if Token.is_kind Token.Verbatim tok then |
|
27874
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
wenzelm
parents:
27809
diff
changeset
|
144 |
let |
|
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
30642
diff
changeset
|
145 |
val (txt, pos) = Token.source_position_of tok; |
| 30642 | 146 |
val ants = Antiquote.read (Symbol_Pos.explode (txt, pos), pos); |
|
27874
f0364f1c0ecf
antiquotes: proper SymbolPos decoding, adapted Antiquote.read/Antiq;
wenzelm
parents:
27809
diff
changeset
|
147 |
val out = implode (map output_syms_antiq ants); |
|
40402
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
148 |
in |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
149 |
out |> enclose |
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
150 |
(enclose_literal "{*" "{\\isacharverbatimopen}")
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
151 |
(enclose_literal "*}" "{\\isacharverbatimclose}")
|
|
b646316f8b3c
basic setup for literal replacement text in PDF, to support copy/paste of Isabelle symbols;
wenzelm
parents:
39666
diff
changeset
|
152 |
end |
| 17081 | 153 |
else output_syms s |
154 |
end; |
|
155 |
||
156 |
fun output_markup cmd txt = "%\n\\isamarkup" ^ cmd ^ "{" ^ Symbol.strip_blanks txt ^ "%\n}\n";
|
|
| 7745 | 157 |
|
| 17081 | 158 |
fun output_markup_env cmd txt = |
159 |
"%\n\\begin{isamarkup" ^ cmd ^ "}%\n" ^
|
|
160 |
Symbol.strip_blanks txt ^ |
|
161 |
"%\n\\end{isamarkup" ^ cmd ^ "}%\n";
|
|
| 7756 | 162 |
|
| 17081 | 163 |
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
|
164 |
|
| 17081 | 165 |
val markup_true = "\\isamarkuptrue%\n"; |
166 |
val markup_false = "\\isamarkupfalse%\n"; |
|
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
167 |
|
| 17081 | 168 |
val begin_delim = enclose "%\n\\isadelim" "\n"; |
169 |
val end_delim = enclose "%\n\\endisadelim" "\n"; |
|
170 |
val begin_tag = enclose "%\n\\isatag" "\n"; |
|
171 |
fun end_tag tg = enclose "%\n\\endisatag" "\n" tg ^ enclose "{\\isafold" "}%\n" tg;
|
|
| 11860 | 172 |
|
173 |
||
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
174 |
(* theory presentation *) |
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
175 |
|
| 9707 | 176 |
val tex_trailer = |
177 |
"%%% Local Variables:\n\ |
|
| 9135 | 178 |
\%%% mode: latex\n\ |
179 |
\%%% TeX-master: \"root\"\n\ |
|
| 9144 | 180 |
\%%% End:\n"; |
| 8192 | 181 |
|
| 9916 | 182 |
fun isabelle_file name txt = |
183 |
"%\n\\begin{isabellebody}%\n\
|
|
| 10247 | 184 |
\\\def\\isabellecontext{" ^ output_syms name ^ "}%\n" ^ txt ^
|
| 9916 | 185 |
"\\end{isabellebody}%\n" ^ tex_trailer;
|
| 9707 | 186 |
|
| 14924 | 187 |
fun symbol_source known name syms = isabelle_file name |
188 |
("\\isamarkupheader{" ^ output_known_symbols known (Symbol.explode name) ^ "}%\n" ^
|
|
189 |
output_known_symbols known syms); |
|
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
190 |
|
|
9038
63d20536971f
session.tex: nsert blank lines in order to guarantee new paragraphs
wenzelm
parents:
8965
diff
changeset
|
191 |
fun theory_entry name = "\\input{" ^ name ^ ".tex}\n\n";
|
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
192 |
|
|
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
193 |
|
| 8460 | 194 |
(* print mode *) |
195 |
||
| 8965 | 196 |
val latexN = "latex"; |
| 17218 | 197 |
val modes = [latexN, Symbol.xsymbolsN]; |
| 8965 | 198 |
|
| 8460 | 199 |
fun latex_output str = |
200 |
let val syms = Symbol.explode str |
|
| 23621 | 201 |
in (output_symbols syms, Symbol.length syms) end; |
| 19265 | 202 |
|
| 23621 | 203 |
fun latex_markup (s, _) = |
204 |
if s = Markup.keywordN then ("\\isakeyword{", "}")
|
|
205 |
else if s = Markup.commandN then ("\\isacommand{", "}")
|
|
| 29325 | 206 |
else Markup.no_output; |
| 10955 | 207 |
|
| 23621 | 208 |
fun latex_indent "" _ = "" |
209 |
| latex_indent s _ = enclose "\\isaindent{" "}" s;
|
|
210 |
||
211 |
val _ = Output.add_mode latexN latex_output Symbol.encode_raw; |
|
| 23703 | 212 |
val _ = Markup.add_mode latexN latex_markup; |
213 |
val _ = Pretty.add_mode latexN latex_indent; |
|
| 8460 | 214 |
|
|
7726
2c7fc0ba1e12
Simple LaTeX presentation primitives (based on outer lexical syntax).
wenzelm
parents:
diff
changeset
|
215 |
end; |