src/Pure/Thy/thy_output.ML
changeset 42508 e21362bf1d93
parent 42399 95b17b4901b5
child 42616 92715b528e78
equal deleted inserted replaced
42507:651aef3cc854 42508:e21362bf1d93
    25   val integer: string -> int
    25   val integer: string -> int
    26   val antiquotation: string -> 'a context_parser ->
    26   val antiquotation: string -> 'a context_parser ->
    27     ({source: Args.src, state: Toplevel.state, context: Proof.context} -> 'a -> string) -> unit
    27     ({source: Args.src, state: Toplevel.state, context: Proof.context} -> 'a -> string) -> unit
    28   datatype markup = Markup | MarkupEnv | Verbatim
    28   datatype markup = Markup | MarkupEnv | Verbatim
    29   val modes: string list Unsynchronized.ref
    29   val modes: string list Unsynchronized.ref
       
    30   val eval_antiq: Scan.lexicon -> Toplevel.state -> Symbol_Pos.T list * Position.range -> string
    30   val eval_antiquote: Scan.lexicon -> Toplevel.state -> Symbol_Pos.text * Position.T -> string
    31   val eval_antiquote: Scan.lexicon -> Toplevel.state -> Symbol_Pos.text * Position.T -> string
    31   val present_thy: Scan.lexicon -> (string -> string list) -> (markup -> string -> bool) ->
    32   val present_thy: Scan.lexicon -> (string -> string list) -> (markup -> string -> bool) ->
    32     (Toplevel.transition * Toplevel.state) list -> (Token.T, 'a) Source.source -> Buffer.T
    33     (Toplevel.transition * Toplevel.state) list -> (Token.T, 'a) Source.source -> Buffer.T
    33   val pretty_text: Proof.context -> string -> Pretty.T
    34   val pretty_text: Proof.context -> string -> Pretty.T
    34   val pretty_term: Proof.context -> term -> Pretty.T
    35   val pretty_term: Proof.context -> term -> Pretty.T
   171 
   172 
   172 (* eval_antiquote *)
   173 (* eval_antiquote *)
   173 
   174 
   174 val modes = Unsynchronized.ref ([]: string list);
   175 val modes = Unsynchronized.ref ([]: string list);
   175 
   176 
       
   177 fun eval_antiq lex state (ss, (pos, _)) =
       
   178   let
       
   179     val (opts, src) = Token.read_antiq lex antiq (ss, pos);
       
   180     fun cmd ctxt = wrap ctxt (fn () => command src state ctxt) ();
       
   181     val preview_ctxt = fold option opts (Toplevel.presentation_context_of state);
       
   182     val print_ctxt = Context_Position.set_visible false preview_ctxt;
       
   183     val _ = cmd preview_ctxt;
       
   184   in Print_Mode.with_modes (! modes @ Latex.modes) (fn () => cmd print_ctxt) () end;
       
   185 
   176 fun eval_antiquote lex state (txt, pos) =
   186 fun eval_antiquote lex state (txt, pos) =
   177   let
   187   let
   178     fun expand (Antiquote.Text ss) = Symbol_Pos.content ss
   188     fun expand (Antiquote.Text ss) = Symbol_Pos.content ss
   179       | expand (Antiquote.Antiq (ss, (pos, _))) =
   189       | expand (Antiquote.Antiq antiq) = eval_antiq lex state antiq
   180           let
       
   181             val (opts, src) = Token.read_antiq lex antiq (ss, pos);
       
   182             fun cmd ctxt = wrap ctxt (fn () => command src state ctxt) ();
       
   183             val preview_ctxt = fold option opts (Toplevel.presentation_context_of state);
       
   184             val print_ctxt = Context_Position.set_visible false preview_ctxt;
       
   185             val _ = cmd preview_ctxt;
       
   186           in Print_Mode.with_modes (! modes @ Latex.modes) (fn () => cmd print_ctxt) () end
       
   187       | expand (Antiquote.Open _) = ""
   190       | expand (Antiquote.Open _) = ""
   188       | expand (Antiquote.Close _) = "";
   191       | expand (Antiquote.Close _) = "";
   189     val ants = Antiquote.read (Symbol_Pos.explode (txt, pos), pos);
   192     val ants = Antiquote.read (Symbol_Pos.explode (txt, pos), pos);
   190   in
   193   in
   191     if Toplevel.is_toplevel state andalso not (forall Antiquote.is_text ants) then
   194     if Toplevel.is_toplevel state andalso not (forall Antiquote.is_text ants) then