equal
deleted
inserted
replaced
32 val index_escape: string -> string |
32 val index_escape: string -> string |
33 type index_item = {text: text, like: string} |
33 type index_item = {text: text, like: string} |
34 val index_item: index_item -> text |
34 val index_item: index_item -> text |
35 type index_entry = {items: index_item list, def: bool} |
35 type index_entry = {items: index_item list, def: bool} |
36 val index_entry: index_entry -> text |
36 val index_entry: index_entry -> text |
|
37 val index_variants: (binding -> bool option -> 'a -> 'a) -> binding -> 'a -> 'a |
37 val latexN: string |
38 val latexN: string |
38 val latex_output: string -> string * int |
39 val latex_output: string -> string * int |
39 val latex_markup: string * Properties.T -> Markup.output |
40 val latex_markup: string * Properties.T -> Markup.output |
40 val latex_indent: string -> int -> string |
41 val latex_indent: string -> int -> string |
41 end; |
42 end; |
256 type index_item = {text: text, like: string}; |
257 type index_item = {text: text, like: string}; |
257 type index_entry = {items: index_item list, def: bool}; |
258 type index_entry = {items: index_item list, def: bool}; |
258 |
259 |
259 val index_escape = |
260 val index_escape = |
260 translate_string (fn s => |
261 translate_string (fn s => |
261 s |> exists_string (fn s' => s = s') "\"\\{}!@|" ? prefix "\""); |
262 if member_string "!\"@|" s then "\\char" ^ string_of_int (ord s) |
|
263 else if member_string "\\{}#" s then "\"" ^ s else s); |
262 |
264 |
263 fun index_item (item: index_item) = |
265 fun index_item (item: index_item) = |
264 let |
266 let |
265 val like_text = |
267 val like_text = |
266 if #like item = "" then [] |
268 if #like item = "" then [] |
271 (separate (string "!") (map index_item (#items entry)) @ |
273 (separate (string "!") (map index_item (#items entry)) @ |
272 [string ("|" ^ index_escape (if #def entry then "isaindexdef" else "isaindexref"))]) |
274 [string ("|" ^ index_escape (if #def entry then "isaindexdef" else "isaindexref"))]) |
273 |> enclose_block "\\index{" "}"; |
275 |> enclose_block "\\index{" "}"; |
274 |
276 |
275 |
277 |
|
278 fun index_binding NONE = I |
|
279 | index_binding (SOME def) = Binding.map_name (suffix (if def then "_def" else "_ref")); |
|
280 |
|
281 fun index_variants setup binding = |
|
282 fold (fn index => setup (index_binding index binding) index) [NONE, SOME true, SOME false]; |
|
283 |
|
284 |
276 (* print mode *) |
285 (* print mode *) |
277 |
286 |
278 val latexN = "latex"; |
287 val latexN = "latex"; |
279 |
288 |
280 fun latex_output str = |
289 fun latex_output str = |