src/Pure/Thy/document_antiquotations.ML
author wenzelm
Mon, 23 May 2016 21:30:30 +0200
changeset 63120 629a4c5e953e
parent 62800 7ac100f86863
child 63679 dc311d55ad8f
permissions -rw-r--r--
embedded content may be delimited via cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62058
1cfd5d604937 updated headers;
wenzelm
parents: 61814
diff changeset
     1
(*  Title:      Pure/Thy/document_antiquotations.ML
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     3
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     4
Miscellaneous document antiquotations.
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     5
*)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     6
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     7
structure Document_Antiquotations: sig end =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     8
struct
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
     9
62153
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    10
(* Markdown errors *)
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    11
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    12
local
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    13
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    14
fun markdown_error binding =
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    15
  Thy_Output.antiquotation binding (Scan.succeed ())
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    16
    (fn {source, ...} => fn _ =>
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    17
      error ("Bad Markdown structure: illegal " ^ quote (Binding.name_of binding) ^
62800
7ac100f86863 tuned signature;
wenzelm
parents: 62520
diff changeset
    18
        Position.here (Position.no_range_position (#1 (Token.range_of source)))))
62153
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    19
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    20
in
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    21
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    22
val _ =
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    23
  Theory.setup
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    24
   (markdown_error @{binding item} #>
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    25
    markdown_error @{binding enum} #>
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    26
    markdown_error @{binding descr});
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    27
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    28
end;
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    29
df566b87e269 more explicit errors for control symbols that are left-over after Markdown parsing;
wenzelm
parents: 62058
diff changeset
    30
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    31
(* control spacing *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    32
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    33
val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    34
  Theory.setup
61704
wenzelm
parents: 61660
diff changeset
    35
   (Thy_Output.antiquotation @{binding noindent} (Scan.succeed ()) (K (K "\\noindent")) #>
wenzelm
parents: 61660
diff changeset
    36
    Thy_Output.antiquotation @{binding smallskip} (Scan.succeed ()) (K (K "\\smallskip")) #>
wenzelm
parents: 61660
diff changeset
    37
    Thy_Output.antiquotation @{binding medskip} (Scan.succeed ()) (K (K "\\medskip")) #>
wenzelm
parents: 61660
diff changeset
    38
    Thy_Output.antiquotation @{binding bigskip} (Scan.succeed ()) (K (K "\\bigskip")));
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    39
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    40
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    41
(* control style *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    42
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    43
local
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    44
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    45
fun control_antiquotation name s1 s2 =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    46
  Thy_Output.antiquotation name (Scan.lift Args.cartouche_input)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    47
    (fn {state, ...} => enclose s1 s2 o Thy_Output.output_text state {markdown = false});
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    48
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    49
in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    50
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    51
val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    52
  Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    53
   (control_antiquotation @{binding footnote} "\\footnote{" "}" #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    54
    control_antiquotation @{binding emph} "\\emph{" "}" #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    55
    control_antiquotation @{binding bold} "\\textbf{" "}");
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    56
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    57
end;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    58
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    59
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    60
(* quasi-formal text (unchecked) *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    61
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    62
local
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    63
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    64
fun text_antiquotation name =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    65
  Thy_Output.antiquotation name (Scan.lift Args.text_input)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    66
    (fn {context = ctxt, ...} => fn source =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    67
     (Context_Position.report ctxt (Input.pos_of source)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    68
        (Markup.language_text (Input.is_delimited source));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    69
      Thy_Output.output ctxt [Thy_Output.pretty_text ctxt (Input.source_content source)]));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    70
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    71
in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    72
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    73
val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    74
  Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    75
   (text_antiquotation @{binding text} #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    76
    text_antiquotation @{binding cartouche});
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    77
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    78
end;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    79
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    80
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    81
(* theory text with tokens (unchecked) *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    82
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    83
val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    84
  Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    85
    (Thy_Output.antiquotation @{binding theory_text} (Scan.lift Args.text_input)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    86
      (fn {context = ctxt, ...} => fn source =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    87
        let
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    88
          val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    89
            Context_Position.report ctxt (Input.pos_of source)
62231
25f4a9cd8b68 tuned markup, e.g. relevant for Rendering.tooltip;
wenzelm
parents: 62153
diff changeset
    90
              (Markup.language_Isar (Input.is_delimited source));
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    91
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    92
          val keywords = Thy_Header.get_keywords' ctxt;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    93
          val toks =
61705
546e6494049f trim lines for @{theory_text} similarly to @{text};
wenzelm
parents: 61704
diff changeset
    94
            Input.source_explode source
546e6494049f trim lines for @{theory_text} similarly to @{text};
wenzelm
parents: 61704
diff changeset
    95
            |> not (Config.get ctxt Thy_Output.display) ? Symbol_Pos.trim_lines
546e6494049f trim lines for @{theory_text} similarly to @{text};
wenzelm
parents: 61704
diff changeset
    96
            |> Source.of_list
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    97
            |> Token.source' true keywords
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    98
            |> Source.exhaust;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
    99
          val _ = Context_Position.reports_text ctxt (maps (Token.reports keywords) toks);
61748
fc53fbf9fe01 observe option "indent";
wenzelm
parents: 61705
diff changeset
   100
          val indentation =
fc53fbf9fe01 observe option "indent";
wenzelm
parents: 61705
diff changeset
   101
            Latex.output_symbols (replicate (Config.get ctxt Thy_Output.indent) Symbol.space);
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   102
        in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   103
          implode (map Latex.output_token toks) |>
61748
fc53fbf9fe01 observe option "indent";
wenzelm
parents: 61705
diff changeset
   104
           (if Config.get ctxt Thy_Output.display then
fc53fbf9fe01 observe option "indent";
wenzelm
parents: 61705
diff changeset
   105
              split_lines #> map (prefix indentation) #> cat_lines #>
fc53fbf9fe01 observe option "indent";
wenzelm
parents: 61705
diff changeset
   106
              Latex.environment "isabelle"
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   107
            else enclose "\\isa{" "}")
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   108
        end));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   109
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   110
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   111
(* goal state *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   112
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   113
local
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   114
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   115
fun goal_state name main = Thy_Output.antiquotation name (Scan.succeed ())
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   116
  (fn {state, context = ctxt, ...} => fn () =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   117
    Thy_Output.output ctxt
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   118
      [Goal_Display.pretty_goal
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   119
        (Config.put Goal_Display.show_main_goal main ctxt)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   120
        (#goal (Proof.goal (Toplevel.proof_of state)))]);
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   121
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   122
in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   123
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   124
val _ = Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   125
 (goal_state @{binding goals} true #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   126
  goal_state @{binding subgoals} false);
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   127
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   128
end;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   129
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   130
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   131
(* embedded lemma *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   132
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   133
val _ = Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   134
  (Thy_Output.antiquotation @{binding lemma}
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   135
    (Scan.lift (Scan.ahead Parse.not_eof) -- Args.prop --
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   136
      Scan.lift (Parse.position (Parse.reserved "by") -- Method.parse -- Scan.option Method.parse))
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   137
    (fn {source, context = ctxt, ...} => fn ((prop_token, prop), (((_, by_pos), m1), m2)) =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   138
      let
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   139
        val reports = (by_pos, Markup.keyword1) :: maps Method.reports_of (m1 :: the_list m2);
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   140
        val _ = Context_Position.reports ctxt reports;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   141
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   142
        (* FIXME check proof!? *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   143
        val _ = ctxt
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   144
          |> Proof.theorem NONE (K I) [[(prop, [])]]
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   145
          |> Proof.global_terminal_proof (m1, m2);
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   146
      in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   147
        Thy_Output.output ctxt
61814
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 61748
diff changeset
   148
          (Thy_Output.maybe_pretty_source
1ca1142e1711 clarified type Token.src: plain token list, with usual implicit value assignment;
wenzelm
parents: 61748
diff changeset
   149
            Thy_Output.pretty_term ctxt [hd source, prop_token] [prop])
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   150
      end));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   151
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   152
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   153
(* verbatim text *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   154
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   155
val _ =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   156
  Theory.setup
62520
2382876c238b more PIDE markup;
wenzelm
parents: 62256
diff changeset
   157
    (Thy_Output.antiquotation @{binding verbatim} (Scan.lift Args.text_input)
2382876c238b more PIDE markup;
wenzelm
parents: 62256
diff changeset
   158
      (fn {context = ctxt, ...} => fn source =>
2382876c238b more PIDE markup;
wenzelm
parents: 62256
diff changeset
   159
       (Context_Position.report ctxt (Input.pos_of source)
2382876c238b more PIDE markup;
wenzelm
parents: 62256
diff changeset
   160
          (Markup.language_verbatim (Input.is_delimited source));
2382876c238b more PIDE markup;
wenzelm
parents: 62256
diff changeset
   161
        Thy_Output.verbatim_text ctxt (Input.source_content source))));
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   162
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   163
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   164
(* ML text *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   165
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   166
local
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   167
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   168
fun ml_text name ml = Thy_Output.antiquotation name (Scan.lift Args.text_input)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   169
  (fn {context = ctxt, ...} => fn source =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   170
   (ML_Context.eval_in (SOME ctxt) ML_Compiler.flags (Input.pos_of source) (ml source);
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   171
    Thy_Output.verbatim_text ctxt (Input.source_content source)));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   172
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   173
fun ml_enclose bg en source =
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   174
  ML_Lex.read bg @ ML_Lex.read_source false source @ ML_Lex.read en;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   175
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   176
in
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   177
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   178
val _ = Theory.setup
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   179
 (ml_text @{binding ML} (ml_enclose "fn _ => (" ");") #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   180
  ml_text @{binding ML_op} (ml_enclose "fn _ => (op " ");") #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   181
  ml_text @{binding ML_type} (ml_enclose "val _ = NONE : (" ") option;") #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   182
  ml_text @{binding ML_structure}
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   183
    (ml_enclose "functor XXX() = struct structure XX = " " end;") #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   184
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   185
  ml_text @{binding ML_functor}   (* FIXME formal treatment of functor name (!?) *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   186
    (fn source =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   187
      ML_Lex.read ("ML_Env.check_functor " ^
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   188
        ML_Syntax.print_string (Input.source_content source))) #>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   189
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   190
  ml_text @{binding ML_text} (K []));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   191
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   192
end;
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   193
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   194
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   195
(* URLs *)
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   196
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   197
val _ = Theory.setup
63120
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 62800
diff changeset
   198
  (Thy_Output.antiquotation @{binding url} (Scan.lift (Parse.position Parse.embedded))
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   199
    (fn {context = ctxt, ...} => fn (name, pos) =>
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   200
      (Context_Position.reports ctxt [(pos, Markup.language_path), (pos, Markup.url name)];
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   201
       enclose "\\url{" "}" name)));
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   202
61623
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   203
61660
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   204
(* doc entries *)
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   205
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   206
val _ = Theory.setup
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   207
  (Thy_Output.antiquotation @{binding doc} (Scan.lift (Parse.position Parse.name))
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   208
    (fn {context = ctxt, ...} => fn (name, pos) =>
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   209
      (Context_Position.report ctxt pos (Markup.doc name);
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   210
        Thy_Output.output ctxt [Thy_Output.pretty_text ctxt name])));
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   211
78b371644654 added antiquotation @{doc}, e.g. useful for demonstration purposes;
wenzelm
parents: 61623
diff changeset
   212
61623
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   213
(* formal entities *)
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   214
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   215
fun entity_antiquotation name check output =
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   216
  Thy_Output.antiquotation name (Scan.lift (Parse.position Args.name))
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   217
    (fn {context = ctxt, ...} => fn (name, pos) => (check ctxt (name, pos); output name));
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   218
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   219
val _ =
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   220
  Theory.setup
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   221
   (entity_antiquotation @{binding command} Outer_Syntax.check_command
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   222
     (enclose "\\isacommand{" "}" o Output.output) #>
62256
614d88f87cfe proper markup for formal text;
wenzelm
parents: 62231
diff changeset
   223
    entity_antiquotation @{binding method} Method.check_name
614d88f87cfe proper markup for formal text;
wenzelm
parents: 62231
diff changeset
   224
     (enclose "\\isa{" "}" o Output.output) #>
614d88f87cfe proper markup for formal text;
wenzelm
parents: 62231
diff changeset
   225
    entity_antiquotation @{binding attribute} Attrib.check_name
614d88f87cfe proper markup for formal text;
wenzelm
parents: 62231
diff changeset
   226
     (enclose "\\isa{" "}" o Output.output));
61623
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61619
diff changeset
   227
61619
f22054b192b0 clarified modules;
wenzelm
parents:
diff changeset
   228
end;