src/Pure/PIDE/markup.ML
author wenzelm
Thu Dec 13 13:52:18 2012 +0100 (2012-12-13 ago)
changeset 50500 c94bba7906d2
parent 50499 f496b2b7bafb
child 50503 50f141b34bb7
permissions -rw-r--r--
identify dialogs via official serial and maintain as result message;
clarified Protocol.is_inlined: suppress result/tracing/state messages uniformly;
cumulate_markup/select_markup depending on command state;
explicit Rendering.output_messages;
tuned source structure;
wenzelm@45670
     1
(*  Title:      Pure/PIDE/markup.ML
wenzelm@23623
     2
    Author:     Makarius
wenzelm@23623
     3
wenzelm@50201
     4
Isabelle-specific implementation of quasi-abstract markup elements.
wenzelm@23623
     5
*)
wenzelm@23623
     6
wenzelm@23623
     7
signature MARKUP =
wenzelm@23623
     8
sig
wenzelm@38414
     9
  val parse_int: string -> int
wenzelm@38414
    10
  val print_int: int -> string
wenzelm@28017
    11
  type T = string * Properties.T
wenzelm@38474
    12
  val empty: T
wenzelm@38474
    13
  val is_empty: T -> bool
wenzelm@38229
    14
  val properties: Properties.T -> T -> T
wenzelm@23623
    15
  val nameN: string
wenzelm@27818
    16
  val name: string -> T -> T
wenzelm@38887
    17
  val kindN: string
wenzelm@50201
    18
  val bindingN: string val binding: T
wenzelm@50201
    19
  val entityN: string val entity: string -> string -> T
wenzelm@50201
    20
  val get_entity_kind: T -> string option
wenzelm@50201
    21
  val defN: string
wenzelm@50201
    22
  val refN: string
wenzelm@50201
    23
  val lineN: string
wenzelm@50201
    24
  val offsetN: string
wenzelm@50201
    25
  val end_offsetN: string
wenzelm@50201
    26
  val fileN: string
wenzelm@50201
    27
  val idN: string
wenzelm@50201
    28
  val position_properties': string list
wenzelm@50201
    29
  val position_properties: string list
wenzelm@50201
    30
  val positionN: string val position: T
wenzelm@50201
    31
  val pathN: string val path: string -> T
wenzelm@50201
    32
  val indentN: string
wenzelm@50201
    33
  val blockN: string val block: int -> T
wenzelm@50201
    34
  val widthN: string
wenzelm@50201
    35
  val breakN: string val break: int -> T
wenzelm@50201
    36
  val fbreakN: string val fbreak: T
wenzelm@50201
    37
  val hiddenN: string val hidden: T
wenzelm@50201
    38
  val theoryN: string
wenzelm@50201
    39
  val classN: string
wenzelm@50201
    40
  val type_nameN: string
wenzelm@50201
    41
  val constantN: string
wenzelm@50201
    42
  val fixedN: string val fixed: string -> T
wenzelm@50201
    43
  val dynamic_factN: string val dynamic_fact: string -> T
wenzelm@50201
    44
  val tfreeN: string val tfree: T
wenzelm@50201
    45
  val tvarN: string val tvar: T
wenzelm@50201
    46
  val freeN: string val free: T
wenzelm@50201
    47
  val skolemN: string val skolem: T
wenzelm@50201
    48
  val boundN: string val bound: T
wenzelm@50201
    49
  val varN: string val var: T
wenzelm@50201
    50
  val numeralN: string val numeral: T
wenzelm@50201
    51
  val literalN: string val literal: T
wenzelm@50201
    52
  val delimiterN: string val delimiter: T
wenzelm@50201
    53
  val inner_stringN: string val inner_string: T
wenzelm@50201
    54
  val inner_commentN: string val inner_comment: T
wenzelm@50201
    55
  val token_rangeN: string val token_range: T
wenzelm@50201
    56
  val sortN: string val sort: T
wenzelm@50201
    57
  val typN: string val typ: T
wenzelm@50201
    58
  val termN: string val term: T
wenzelm@50201
    59
  val propN: string val prop: T
wenzelm@50201
    60
  val sortingN: string val sorting: T
wenzelm@50201
    61
  val typingN: string val typing: T
wenzelm@50201
    62
  val ML_keywordN: string val ML_keyword: T
wenzelm@50201
    63
  val ML_delimiterN: string val ML_delimiter: T
wenzelm@50201
    64
  val ML_tvarN: string val ML_tvar: T
wenzelm@50201
    65
  val ML_numeralN: string val ML_numeral: T
wenzelm@50201
    66
  val ML_charN: string val ML_char: T
wenzelm@50201
    67
  val ML_stringN: string val ML_string: T
wenzelm@50201
    68
  val ML_commentN: string val ML_comment: T
wenzelm@50201
    69
  val ML_defN: string
wenzelm@50201
    70
  val ML_openN: string
wenzelm@50201
    71
  val ML_structN: string
wenzelm@50201
    72
  val ML_typingN: string val ML_typing: T
wenzelm@50201
    73
  val ML_sourceN: string val ML_source: T
wenzelm@50201
    74
  val doc_sourceN: string val doc_source: T
wenzelm@50201
    75
  val antiqN: string val antiq: T
wenzelm@50201
    76
  val ML_antiquotationN: string
wenzelm@50201
    77
  val document_antiquotationN: string
wenzelm@50201
    78
  val document_antiquotation_optionN: string
wenzelm@50201
    79
  val paragraphN: string val paragraph: T
wenzelm@50201
    80
  val keywordN: string val keyword: T
wenzelm@50201
    81
  val operatorN: string val operator: T
wenzelm@50201
    82
  val commandN: string val command: T
wenzelm@50201
    83
  val stringN: string val string: T
wenzelm@50201
    84
  val altstringN: string val altstring: T
wenzelm@50201
    85
  val verbatimN: string val verbatim: T
wenzelm@50201
    86
  val commentN: string val comment: T
wenzelm@50201
    87
  val controlN: string val control: T
wenzelm@50201
    88
  val tokenN: string val token: Properties.T -> T
wenzelm@50201
    89
  val keyword1N: string val keyword1: T
wenzelm@50201
    90
  val keyword2N: string val keyword2: T
wenzelm@50201
    91
  val elapsedN: string
wenzelm@50201
    92
  val cpuN: string
wenzelm@50201
    93
  val gcN: string
wenzelm@50201
    94
  val timingN: string val timing: Timing.timing -> T
wenzelm@50201
    95
  val subgoalsN: string
wenzelm@50201
    96
  val proof_stateN: string val proof_state: int -> T
wenzelm@50201
    97
  val stateN: string val state: T
wenzelm@50201
    98
  val subgoalN: string val subgoal: T
wenzelm@50201
    99
  val taskN: string
wenzelm@50201
   100
  val acceptedN: string val accepted: T
wenzelm@50201
   101
  val forkedN: string val forked: T
wenzelm@50201
   102
  val joinedN: string val joined: T
wenzelm@50201
   103
  val runningN: string val running: T
wenzelm@50201
   104
  val finishedN: string val finished: T
wenzelm@50201
   105
  val failedN: string val failed: T
wenzelm@50201
   106
  val serialN: string
wenzelm@50201
   107
  val initN: string
wenzelm@50201
   108
  val statusN: string
wenzelm@50201
   109
  val writelnN: string
wenzelm@50201
   110
  val tracingN: string
wenzelm@50201
   111
  val warningN: string
wenzelm@50201
   112
  val errorN: string
wenzelm@50201
   113
  val protocolN: string
wenzelm@50201
   114
  val legacyN: string val legacy: T
wenzelm@50201
   115
  val promptN: string val prompt: T
wenzelm@50201
   116
  val reportN: string val report: T
wenzelm@50201
   117
  val no_reportN: string val no_report: T
wenzelm@50201
   118
  val badN: string val bad: T
wenzelm@50500
   119
  val intensifyN: string val intensify: T
wenzelm@50500
   120
  val graphviewN: string
wenzelm@50500
   121
  val sendbackN: string
wenzelm@50500
   122
  val paddingN: string
wenzelm@50500
   123
  val padding_line: string * string
wenzelm@50500
   124
  val dialogN: string val dialog: serial -> string -> T
wenzelm@50201
   125
  val functionN: string
wenzelm@50201
   126
  val assign_execs: Properties.T
wenzelm@50201
   127
  val removed_versions: Properties.T
wenzelm@50201
   128
  val invoke_scala: string -> string -> Properties.T
wenzelm@50201
   129
  val cancel_scala: string -> Properties.T
wenzelm@50255
   130
  val ML_statistics: Properties.T
wenzelm@40131
   131
  val no_output: Output.output * Output.output
wenzelm@40131
   132
  val default_output: T -> Output.output * Output.output
wenzelm@40131
   133
  val add_mode: string -> (T -> Output.output * Output.output) -> unit
wenzelm@40131
   134
  val output: T -> Output.output * Output.output
wenzelm@40131
   135
  val enclose: T -> Output.output -> Output.output
wenzelm@25552
   136
  val markup: T -> string -> string
wenzelm@43665
   137
  val markup_only: T -> string
wenzelm@23623
   138
end;
wenzelm@23623
   139
wenzelm@23623
   140
structure Markup: MARKUP =
wenzelm@23623
   141
struct
wenzelm@23623
   142
wenzelm@30221
   143
(** markup elements **)
wenzelm@30221
   144
wenzelm@38414
   145
(* integers *)
wenzelm@38414
   146
wenzelm@38414
   147
fun parse_int s =
wenzelm@43797
   148
  let val i = Int.fromString s in
wenzelm@43797
   149
    if is_none i orelse String.isPrefix "~" s
wenzelm@43797
   150
    then raise Fail ("Bad integer: " ^ quote s)
wenzelm@43797
   151
    else the i
wenzelm@43797
   152
  end;
wenzelm@38414
   153
wenzelm@38414
   154
val print_int = signed_string_of_int;
wenzelm@38414
   155
wenzelm@38414
   156
wenzelm@23658
   157
(* basic markup *)
wenzelm@23623
   158
wenzelm@28017
   159
type T = string * Properties.T;
wenzelm@23637
   160
wenzelm@38474
   161
val empty = ("", []);
wenzelm@23637
   162
wenzelm@38474
   163
fun is_empty ("", _) = true
wenzelm@38474
   164
  | is_empty _ = false;
wenzelm@27883
   165
wenzelm@23794
   166
wenzelm@23671
   167
fun properties more_props ((elem, props): T) =
wenzelm@28017
   168
  (elem, fold_rev Properties.put more_props props);
wenzelm@23671
   169
wenzelm@50201
   170
fun markup_elem elem = (elem, (elem, []): T);
wenzelm@50201
   171
fun markup_string elem prop = (elem, fn s => (elem, [(prop, s)]): T);
wenzelm@50201
   172
fun markup_int elem prop = (elem, fn i => (elem, [(prop, print_int i)]): T);
wenzelm@50201
   173
wenzelm@26977
   174
wenzelm@38721
   175
(* misc properties *)
wenzelm@26977
   176
wenzelm@23658
   177
val nameN = "name";
wenzelm@27818
   178
fun name a = properties [(nameN, a)];
wenzelm@27818
   179
wenzelm@23658
   180
val kindN = "kind";
wenzelm@23671
   181
wenzelm@23658
   182
wenzelm@50201
   183
(* formal entities *)
wenzelm@50201
   184
wenzelm@50201
   185
val (bindingN, binding) = markup_elem "binding";
wenzelm@50201
   186
wenzelm@50201
   187
val entityN = "entity";
wenzelm@50201
   188
fun entity kind name = (entityN, [(nameN, name), (kindN, kind)]);
wenzelm@50201
   189
wenzelm@50201
   190
fun get_entity_kind (name, props) =
wenzelm@50201
   191
  if name = entityN then AList.lookup (op =) props kindN
wenzelm@50201
   192
  else NONE;
wenzelm@50201
   193
wenzelm@50201
   194
val defN = "def";
wenzelm@50201
   195
val refN = "ref";
wenzelm@50201
   196
wenzelm@50201
   197
wenzelm@50201
   198
(* position *)
wenzelm@50201
   199
wenzelm@50201
   200
val lineN = "line";
wenzelm@50201
   201
val offsetN = "offset";
wenzelm@50201
   202
val end_offsetN = "end_offset";
wenzelm@50201
   203
val fileN = "file";
wenzelm@50201
   204
val idN = "id";
wenzelm@50201
   205
wenzelm@50201
   206
val position_properties' = [fileN, idN];
wenzelm@50201
   207
val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
wenzelm@50201
   208
wenzelm@50201
   209
val (positionN, position) = markup_elem "position";
wenzelm@50201
   210
wenzelm@50201
   211
wenzelm@50201
   212
(* path *)
wenzelm@50201
   213
wenzelm@50201
   214
val (pathN, path) = markup_string "path" nameN;
wenzelm@50201
   215
wenzelm@50201
   216
wenzelm@50201
   217
(* pretty printing *)
wenzelm@50201
   218
wenzelm@50201
   219
val indentN = "indent";
wenzelm@50201
   220
val (blockN, block) = markup_int "block" indentN;
wenzelm@50201
   221
wenzelm@50201
   222
val widthN = "width";
wenzelm@50201
   223
val (breakN, break) = markup_int "break" widthN;
wenzelm@50201
   224
wenzelm@50201
   225
val (fbreakN, fbreak) = markup_elem "fbreak";
wenzelm@50201
   226
wenzelm@50201
   227
wenzelm@50201
   228
(* hidden text *)
wenzelm@50201
   229
wenzelm@50201
   230
val (hiddenN, hidden) = markup_elem "hidden";
wenzelm@50201
   231
wenzelm@50201
   232
wenzelm@50201
   233
(* logical entities *)
wenzelm@50201
   234
wenzelm@50201
   235
val theoryN = "theory";
wenzelm@50201
   236
val classN = "class";
wenzelm@50201
   237
val type_nameN = "type_name";
wenzelm@50201
   238
val constantN = "constant";
wenzelm@50201
   239
wenzelm@50201
   240
val (fixedN, fixed) = markup_string "fixed" nameN;
wenzelm@50201
   241
val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN;
wenzelm@50201
   242
wenzelm@50201
   243
wenzelm@50201
   244
(* inner syntax *)
wenzelm@50201
   245
wenzelm@50201
   246
val (tfreeN, tfree) = markup_elem "tfree";
wenzelm@50201
   247
val (tvarN, tvar) = markup_elem "tvar";
wenzelm@50201
   248
val (freeN, free) = markup_elem "free";
wenzelm@50201
   249
val (skolemN, skolem) = markup_elem "skolem";
wenzelm@50201
   250
val (boundN, bound) = markup_elem "bound";
wenzelm@50201
   251
val (varN, var) = markup_elem "var";
wenzelm@50201
   252
val (numeralN, numeral) = markup_elem "numeral";
wenzelm@50201
   253
val (literalN, literal) = markup_elem "literal";
wenzelm@50201
   254
val (delimiterN, delimiter) = markup_elem "delimiter";
wenzelm@50201
   255
val (inner_stringN, inner_string) = markup_elem "inner_string";
wenzelm@50201
   256
val (inner_commentN, inner_comment) = markup_elem "inner_comment";
wenzelm@50201
   257
wenzelm@50201
   258
val (token_rangeN, token_range) = markup_elem "token_range";
wenzelm@50201
   259
wenzelm@50201
   260
val (sortN, sort) = markup_elem "sort";
wenzelm@50201
   261
val (typN, typ) = markup_elem "typ";
wenzelm@50201
   262
val (termN, term) = markup_elem "term";
wenzelm@50201
   263
val (propN, prop) = markup_elem "prop";
wenzelm@50201
   264
wenzelm@50201
   265
val (sortingN, sorting) = markup_elem "sorting";
wenzelm@50201
   266
val (typingN, typing) = markup_elem "typing";
wenzelm@50201
   267
wenzelm@50201
   268
wenzelm@50201
   269
(* ML syntax *)
wenzelm@50201
   270
wenzelm@50201
   271
val (ML_keywordN, ML_keyword) = markup_elem "ML_keyword";
wenzelm@50201
   272
val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
wenzelm@50201
   273
val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
wenzelm@50201
   274
val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
wenzelm@50201
   275
val (ML_charN, ML_char) = markup_elem "ML_char";
wenzelm@50201
   276
val (ML_stringN, ML_string) = markup_elem "ML_string";
wenzelm@50201
   277
val (ML_commentN, ML_comment) = markup_elem "ML_comment";
wenzelm@50201
   278
wenzelm@50201
   279
val ML_defN = "ML_def";
wenzelm@50201
   280
val ML_openN = "ML_open";
wenzelm@50201
   281
val ML_structN = "ML_struct";
wenzelm@50201
   282
val (ML_typingN, ML_typing) = markup_elem "ML_typing";
wenzelm@50201
   283
wenzelm@50201
   284
wenzelm@50201
   285
(* embedded source text *)
wenzelm@50201
   286
wenzelm@50201
   287
val (ML_sourceN, ML_source) = markup_elem "ML_source";
wenzelm@50201
   288
val (doc_sourceN, doc_source) = markup_elem "doc_source";
wenzelm@50201
   289
wenzelm@50201
   290
val (antiqN, antiq) = markup_elem "antiq";
wenzelm@50201
   291
val ML_antiquotationN = "ML_antiquotation";
wenzelm@50201
   292
val document_antiquotationN = "document_antiquotation";
wenzelm@50201
   293
val document_antiquotation_optionN = "document_antiquotation_option";
wenzelm@50201
   294
wenzelm@50201
   295
wenzelm@50201
   296
(* text structure *)
wenzelm@50201
   297
wenzelm@50201
   298
val (paragraphN, paragraph) = markup_elem "paragraph";
wenzelm@50201
   299
wenzelm@50201
   300
wenzelm@50201
   301
(* outer syntax *)
wenzelm@50201
   302
wenzelm@50201
   303
val (keywordN, keyword) = markup_elem "keyword";
wenzelm@50201
   304
val (operatorN, operator) = markup_elem "operator";
wenzelm@50201
   305
val (commandN, command) = markup_elem "command";
wenzelm@50201
   306
val (stringN, string) = markup_elem "string";
wenzelm@50201
   307
val (altstringN, altstring) = markup_elem "altstring";
wenzelm@50201
   308
val (verbatimN, verbatim) = markup_elem "verbatim";
wenzelm@50201
   309
val (commentN, comment) = markup_elem "comment";
wenzelm@50201
   310
val (controlN, control) = markup_elem "control";
wenzelm@50201
   311
wenzelm@50201
   312
val tokenN = "token";
wenzelm@50201
   313
fun token props = (tokenN, props);
wenzelm@50201
   314
wenzelm@50201
   315
val (keyword1N, keyword1) = markup_elem "keyword1";
wenzelm@50201
   316
val (keyword2N, keyword2) = markup_elem "keyword2";
wenzelm@50201
   317
wenzelm@50201
   318
wenzelm@50201
   319
(* timing *)
wenzelm@50201
   320
wenzelm@50201
   321
val timingN = "timing";
wenzelm@50201
   322
val elapsedN = "elapsed";
wenzelm@50201
   323
val cpuN = "cpu";
wenzelm@50201
   324
val gcN = "gc";
wenzelm@50201
   325
wenzelm@50201
   326
fun timing {elapsed, cpu, gc} =
wenzelm@50201
   327
  (timingN,
wenzelm@50201
   328
   [(elapsedN, Time.toString elapsed),
wenzelm@50201
   329
    (cpuN, Time.toString cpu),
wenzelm@50201
   330
    (gcN, Time.toString gc)]);
wenzelm@50201
   331
wenzelm@50201
   332
wenzelm@50201
   333
(* toplevel *)
wenzelm@50201
   334
wenzelm@50201
   335
val subgoalsN = "subgoals";
wenzelm@50201
   336
val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
wenzelm@50201
   337
wenzelm@50201
   338
val (stateN, state) = markup_elem "state";
wenzelm@50201
   339
val (subgoalN, subgoal) = markup_elem "subgoal";
wenzelm@50215
   340
wenzelm@50450
   341
wenzelm@50201
   342
(* command status *)
wenzelm@50201
   343
wenzelm@50201
   344
val taskN = "task";
wenzelm@50201
   345
wenzelm@50201
   346
val (acceptedN, accepted) = markup_elem "accepted";
wenzelm@50201
   347
val (forkedN, forked) = markup_elem "forked";
wenzelm@50201
   348
val (joinedN, joined) = markup_elem "joined";
wenzelm@50201
   349
val (runningN, running) = markup_elem "running";
wenzelm@50201
   350
val (finishedN, finished) = markup_elem "finished";
wenzelm@50201
   351
val (failedN, failed) = markup_elem "failed";
wenzelm@50201
   352
wenzelm@50201
   353
wenzelm@50201
   354
(* messages *)
wenzelm@50201
   355
wenzelm@50201
   356
val serialN = "serial";
wenzelm@50201
   357
wenzelm@50201
   358
val initN = "init";
wenzelm@50201
   359
val statusN = "status";
wenzelm@50201
   360
val writelnN = "writeln";
wenzelm@50201
   361
val tracingN = "tracing";
wenzelm@50201
   362
val warningN = "warning";
wenzelm@50201
   363
val errorN = "error";
wenzelm@50201
   364
val protocolN = "protocol";
wenzelm@50201
   365
wenzelm@50201
   366
val (legacyN, legacy) = markup_elem "legacy";
wenzelm@50201
   367
val (promptN, prompt) = markup_elem "prompt";
wenzelm@50201
   368
wenzelm@50201
   369
val (reportN, report) = markup_elem "report";
wenzelm@50201
   370
val (no_reportN, no_report) = markup_elem "no_report";
wenzelm@50201
   371
wenzelm@50201
   372
val (badN, bad) = markup_elem "bad";
wenzelm@50201
   373
wenzelm@50500
   374
val (intensifyN, intensify) = markup_elem "intensify";
wenzelm@50500
   375
wenzelm@50500
   376
wenzelm@50500
   377
(* active areas *)
wenzelm@50500
   378
wenzelm@50500
   379
val graphviewN = "graphview";
wenzelm@50500
   380
wenzelm@50500
   381
val sendbackN = "sendback";
wenzelm@50500
   382
val paddingN = "padding";
wenzelm@50500
   383
val padding_line = (paddingN, lineN);
wenzelm@50500
   384
wenzelm@50500
   385
val dialogN = "dialog";
wenzelm@50500
   386
fun dialog i result = (dialogN, [(serialN, print_int i), ("result", result)]);
wenzelm@50500
   387
wenzelm@50201
   388
wenzelm@50201
   389
(* protocol message functions *)
wenzelm@50201
   390
wenzelm@50201
   391
val functionN = "function"
wenzelm@50201
   392
wenzelm@50201
   393
val assign_execs = [(functionN, "assign_execs")];
wenzelm@50201
   394
val removed_versions = [(functionN, "removed_versions")];
wenzelm@50201
   395
wenzelm@50201
   396
fun invoke_scala name id = [(functionN, "invoke_scala"), (nameN, name), (idN, id)];
wenzelm@50201
   397
fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
wenzelm@50201
   398
wenzelm@50255
   399
val ML_statistics = [(functionN, "ML_statistics")];
wenzelm@50255
   400
wenzelm@50201
   401
wenzelm@27969
   402
wenzelm@30221
   403
(** print mode operations **)
wenzelm@23704
   404
wenzelm@29325
   405
val no_output = ("", "");
wenzelm@29325
   406
fun default_output (_: T) = no_output;
wenzelm@23704
   407
wenzelm@23704
   408
local
wenzelm@23704
   409
  val default = {output = default_output};
wenzelm@43684
   410
  val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default)]);
wenzelm@23704
   411
in
wenzelm@43684
   412
  fun add_mode name output =
wenzelm@46894
   413
    Synchronized.change modes (fn tab =>
wenzelm@46894
   414
      (if not (Symtab.defined tab name) then ()
wenzelm@46894
   415
       else warning ("Redefining markup mode " ^ quote name);
wenzelm@46894
   416
       Symtab.update (name, {output = output}) tab));
wenzelm@23704
   417
  fun get_mode () =
wenzelm@43684
   418
    the_default default
wenzelm@43684
   419
      (Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ()));
wenzelm@23623
   420
end;
wenzelm@23704
   421
wenzelm@38474
   422
fun output m = if is_empty m then no_output else #output (get_mode ()) m;
wenzelm@23704
   423
wenzelm@23719
   424
val enclose = output #-> Library.enclose;
wenzelm@23719
   425
wenzelm@25552
   426
fun markup m =
wenzelm@25552
   427
  let val (bg, en) = output m
wenzelm@25552
   428
  in Library.enclose (Output.escape bg) (Output.escape en) end;
wenzelm@25552
   429
wenzelm@43665
   430
fun markup_only m = markup m "";
wenzelm@43665
   431
wenzelm@23704
   432
end;