src/Pure/Thy/thy_output.ML
changeset 67358 dfee70a24f0c
parent 67357 d7c6054b2ab1
child 67359 fed0e220be45
equal deleted inserted replaced
67357:d7c6054b2ab1 67358:dfee70a24f0c
   262   Scan.many1 (fn (s, _) => s <> Symbol.comment andalso Symbol.not_eof s) >> pair false ||
   262   Scan.many1 (fn (s, _) => s <> Symbol.comment andalso Symbol.not_eof s) >> pair false ||
   263   (Symbol_Pos.$$ Symbol.comment ::: Scan.many (Symbol.is_blank o Symbol_Pos.symbol)) --
   263   (Symbol_Pos.$$ Symbol.comment ::: Scan.many (Symbol.is_blank o Symbol_Pos.symbol)) --
   264     Scan.option (Symbol_Pos.scan_cartouche_content "Document token error: ")
   264     Scan.option (Symbol_Pos.scan_cartouche_content "Document token error: ")
   265       >> (fn (syms, NONE) => (false, syms) | (_, SOME syms) => (true, syms));
   265       >> (fn (syms, NONE) => (false, syms) | (_, SOME syms) => (true, syms));
   266 
   266 
   267 val output_syms_antiq =
   267 val output_symbols_antiq =
   268   (fn Antiquote.Text ss => Latex.output_symbols_pos ss
   268   (fn Antiquote.Text syms => output_symbols syms
   269     | Antiquote.Control {name = (name, _), body, ...} =>
   269     | Antiquote.Control {name = (name, _), body, ...} =>
   270         "\\isaantiqcontrol{" ^ Latex.output_symbols (Symbol.explode name) ^ "}" ^
   270         Latex.string ("\\isaantiqcontrol{" ^ Latex.output_symbols (Symbol.explode name) ^ "}") ::
   271         Latex.output_symbols_pos body
   271           output_symbols body
   272     | Antiquote.Antiq {body, ...} =>
   272     | Antiquote.Antiq {body, ...} =>
   273         enclose "%\n\\isaantiq\n" "{}%\n\\endisaantiq\n" (Latex.output_symbols_pos body));
   273         Latex.enclose_body "%\n\\isaantiq\n" "{}%\n\\endisaantiq\n" (output_symbols body));
   274 
   274 
   275 in
   275 in
   276 
   276 
   277 fun output_body state bg en syms =
   277 fun output_body state bg en syms =
   278   (if exists (fn (s, _) => s = Symbol.comment) syms then
   278   (if exists (fn (s, _) => s = Symbol.comment) syms then
   292       else if Token.is_kind Token.String tok then
   292       else if Token.is_kind Token.String tok then
   293         output_body state "{\\isachardoublequoteopen}" "{\\isachardoublequoteclose}" syms
   293         output_body state "{\\isachardoublequoteopen}" "{\\isachardoublequoteclose}" syms
   294       else if Token.is_kind Token.Alt_String tok then
   294       else if Token.is_kind Token.Alt_String tok then
   295         output_body state "{\\isacharbackquoteopen}" "{\\isacharbackquoteclose}" syms
   295         output_body state "{\\isacharbackquoteopen}" "{\\isacharbackquoteclose}" syms
   296       else if Token.is_kind Token.Verbatim tok then
   296       else if Token.is_kind Token.Verbatim tok then
   297         let
   297         Latex.enclose_body "{\\isacharverbatimopen}" "{\\isacharverbatimclose}"
   298           val pos = Token.pos_of tok;
   298           (maps output_symbols_antiq (Antiquote.read (Token.input_of tok)))
   299           val ants = Antiquote.read (Token.input_of tok);
       
   300           val out = implode (map output_syms_antiq ants);
       
   301         in [Latex.text (enclose "{\\isacharverbatimopen}" "{\\isacharverbatimclose}" out, pos)] end
       
   302       else if Token.is_kind Token.Cartouche tok then
   299       else if Token.is_kind Token.Cartouche tok then
   303         output_body state "{\\isacartoucheopen}" "{\\isacartoucheclose}" syms
   300         output_body state "{\\isacartoucheopen}" "{\\isacartoucheclose}" syms
   304       else output_body state "" "" syms;
   301       else output_body state "" "" syms;
   305   in output end
   302   in output end
   306   handle ERROR msg => error (msg ^ Position.here (Token.pos_of tok));
   303   handle ERROR msg => error (msg ^ Position.here (Token.pos_of tok));