src/Pure/PIDE/markup.ML
author wenzelm
Sun Oct 05 17:58:36 2014 +0200 (2014-10-05 ago)
changeset 58545 30b75b7958d6
parent 58544 340f130b3d38
child 58850 1bb0ad7827b4
permissions -rw-r--r--
citation tooltip/hyperlink based on open buffers with .bib files;
     1 (*  Title:      Pure/PIDE/markup.ML
     2     Author:     Makarius
     3 
     4 Quasi-abstract markup elements.
     5 *)
     6 
     7 signature MARKUP =
     8 sig
     9   val parse_bool: string -> bool
    10   val print_bool: bool -> string
    11   val parse_int: string -> int
    12   val print_int: int -> string
    13   val parse_real: string -> real
    14   val print_real: real -> string
    15   type T = string * Properties.T
    16   val empty: T
    17   val is_empty: T -> bool
    18   val properties: Properties.T -> T -> T
    19   val nameN: string
    20   val name: string -> T -> T
    21   val kindN: string
    22   val instanceN: string
    23   val languageN: string
    24   val symbolsN: string
    25   val delimitedN: string
    26   val is_delimited: Properties.T -> bool
    27   val language: {name: string, symbols: bool, antiquotes: bool, delimited: bool} -> T
    28   val language': {name: string, symbols: bool, antiquotes: bool} -> bool -> T
    29   val language_method: T
    30   val language_attribute: T
    31   val language_sort: bool -> T
    32   val language_type: bool -> T
    33   val language_term: bool -> T
    34   val language_prop: bool -> T
    35   val language_ML: bool -> T
    36   val language_SML: bool -> T
    37   val language_document: bool -> T
    38   val language_antiquotation: T
    39   val language_text: bool -> T
    40   val language_rail: T
    41   val language_path: T
    42   val bindingN: string val binding: T
    43   val entityN: string val entity: string -> string -> T
    44   val get_entity_kind: T -> string option
    45   val defN: string
    46   val refN: string
    47   val completionN: string val completion: T
    48   val no_completionN: string val no_completion: T
    49   val lineN: string
    50   val offsetN: string
    51   val end_offsetN: string
    52   val fileN: string
    53   val idN: string
    54   val position_properties': string list
    55   val position_properties: string list
    56   val positionN: string val position: T
    57   val expressionN: string val expression: T
    58   val citationN: string val citation: string -> T
    59   val pathN: string val path: string -> T
    60   val urlN: string val url: string -> T
    61   val indentN: string
    62   val blockN: string val block: int -> T
    63   val widthN: string
    64   val breakN: string val break: int -> T
    65   val fbreakN: string val fbreak: T
    66   val itemN: string val item: T
    67   val wordsN: string val words: T
    68   val hiddenN: string val hidden: T
    69   val system_optionN: string
    70   val theoryN: string
    71   val classN: string
    72   val type_nameN: string
    73   val constantN: string
    74   val fixedN: string val fixed: string -> T
    75   val caseN: string val case_: string -> T
    76   val dynamic_factN: string val dynamic_fact: string -> T
    77   val method_modifierN: string
    78   val tfreeN: string val tfree: T
    79   val tvarN: string val tvar: T
    80   val freeN: string val free: T
    81   val skolemN: string val skolem: T
    82   val boundN: string val bound: T
    83   val varN: string val var: T
    84   val numeralN: string val numeral: T
    85   val literalN: string val literal: T
    86   val delimiterN: string val delimiter: T
    87   val inner_stringN: string val inner_string: T
    88   val inner_cartoucheN: string val inner_cartouche: T
    89   val inner_commentN: string val inner_comment: T
    90   val token_rangeN: string val token_range: T
    91   val sortingN: string val sorting: T
    92   val typingN: string val typing: T
    93   val ML_keyword1N: string val ML_keyword1: T
    94   val ML_keyword2N: string val ML_keyword2: T
    95   val ML_keyword3N: string val ML_keyword3: T
    96   val ML_delimiterN: string val ML_delimiter: T
    97   val ML_tvarN: string val ML_tvar: T
    98   val ML_numeralN: string val ML_numeral: T
    99   val ML_charN: string val ML_char: T
   100   val ML_stringN: string val ML_string: T
   101   val ML_commentN: string val ML_comment: T
   102   val SML_stringN: string val SML_string: T
   103   val SML_commentN: string val SML_comment: T
   104   val ML_defN: string
   105   val ML_openN: string
   106   val ML_structureN: string
   107   val ML_typingN: string val ML_typing: T
   108   val antiquotedN: string val antiquoted: T
   109   val antiquoteN: string val antiquote: T
   110   val ML_antiquotationN: string
   111   val document_antiquotationN: string
   112   val document_antiquotation_optionN: string
   113   val paragraphN: string val paragraph: T
   114   val text_foldN: string val text_fold: T
   115   val commandN: string val command: T
   116   val stringN: string val string: T
   117   val altstringN: string val altstring: T
   118   val verbatimN: string val verbatim: T
   119   val cartoucheN: string val cartouche: T
   120   val commentN: string val comment: T
   121   val controlN: string val control: T
   122   val tokenN: string val token: bool -> Properties.T -> T
   123   val keyword1N: string val keyword1: T
   124   val keyword2N: string val keyword2: T
   125   val keyword3N: string val keyword3: T
   126   val quasi_keywordN: string val quasi_keyword: T
   127   val improperN: string val improper: T
   128   val operatorN: string val operator: T
   129   val elapsedN: string
   130   val cpuN: string
   131   val gcN: string
   132   val timing_properties: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> Properties.T
   133   val parse_timing_properties: Properties.T -> {elapsed: Time.time, cpu: Time.time, gc: Time.time}
   134   val command_timingN: string
   135   val command_timing_properties:
   136     {file: string, offset: int, name: string} -> Time.time -> Properties.T
   137   val parse_command_timing_properties:
   138     Properties.T -> ({file: string, offset: int, name: string} * Time.time) option
   139   val timingN: string val timing: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> T
   140   val subgoalsN: string
   141   val proof_stateN: string val proof_state: int -> T
   142   val stateN: string val state: T
   143   val goalN: string val goal: T
   144   val subgoalN: string val subgoal: string -> T
   145   val taskN: string
   146   val acceptedN: string val accepted: T
   147   val forkedN: string val forked: T
   148   val joinedN: string val joined: T
   149   val runningN: string val running: T
   150   val finishedN: string val finished: T
   151   val failedN: string val failed: T
   152   val serialN: string
   153   val serial_properties: int -> Properties.T
   154   val exec_idN: string
   155   val initN: string
   156   val statusN: string
   157   val resultN: string
   158   val writelnN: string
   159   val tracingN: string
   160   val warningN: string
   161   val errorN: string
   162   val systemN: string
   163   val protocolN: string
   164   val legacyN: string val legacy: T
   165   val promptN: string val prompt: T
   166   val reportN: string val report: T
   167   val no_reportN: string val no_report: T
   168   val badN: string val bad: T
   169   val intensifyN: string val intensify: T
   170   val informationN: string val information: T
   171   val browserN: string
   172   val graphviewN: string
   173   val sendbackN: string
   174   val paddingN: string
   175   val padding_line: Properties.entry
   176   val padding_command: Properties.entry
   177   val dialogN: string val dialog: serial -> string -> T
   178   val functionN: string
   179   val assign_update: Properties.T
   180   val removed_versions: Properties.T
   181   val protocol_handler: string -> Properties.T
   182   val invoke_scala: string -> string -> Properties.T
   183   val cancel_scala: string -> Properties.T
   184   val ML_statistics: Properties.entry
   185   val task_statistics: Properties.entry
   186   val command_timing: Properties.entry
   187   val loading_theory: string -> Properties.T
   188   val dest_loading_theory: Properties.T -> string option
   189   val use_theories_result: string -> bool -> Properties.T
   190   val print_operationsN: string
   191   val print_operations: Properties.T
   192   val simp_trace_panelN: string
   193   val simp_trace_logN: string
   194   val simp_trace_stepN: string
   195   val simp_trace_recurseN: string
   196   val simp_trace_hintN: string
   197   val simp_trace_ignoreN: string
   198   val simp_trace_cancel: serial -> Properties.T
   199   val no_output: Output.output * Output.output
   200   val default_output: T -> Output.output * Output.output
   201   val add_mode: string -> (T -> Output.output * Output.output) -> unit
   202   val output: T -> Output.output * Output.output
   203   val enclose: T -> Output.output -> Output.output
   204   val markup: T -> string -> string
   205   val markup_only: T -> string
   206   val markup_report: string -> string
   207 end;
   208 
   209 structure Markup: MARKUP =
   210 struct
   211 
   212 (** markup elements **)
   213 
   214 (* misc values *)
   215 
   216 fun parse_bool "true" = true
   217   | parse_bool "false" = false
   218   | parse_bool s = raise Fail ("Bad boolean: " ^ quote s);
   219 
   220 val print_bool = Bool.toString;
   221 
   222 fun parse_int s =
   223   let val i = Int.fromString s in
   224     if is_none i orelse String.isPrefix "~" s
   225     then raise Fail ("Bad integer: " ^ quote s)
   226     else the i
   227   end;
   228 
   229 val print_int = signed_string_of_int;
   230 
   231 fun parse_real s =
   232   (case Real.fromString s of
   233     SOME x => x
   234   | NONE => raise Fail ("Bad real: " ^ quote s));
   235 
   236 fun print_real x =
   237   let val s = signed_string_of_real x in
   238     (case space_explode "." s of
   239       [a, b] => if forall_string (fn c => c = "0") b then a else s
   240     | _ => s)
   241   end;
   242 
   243 
   244 (* basic markup *)
   245 
   246 type T = string * Properties.T;
   247 
   248 val empty = ("", []);
   249 
   250 fun is_empty ("", _) = true
   251   | is_empty _ = false;
   252 
   253 
   254 fun properties more_props ((elem, props): T) =
   255   (elem, fold_rev Properties.put more_props props);
   256 
   257 fun markup_elem name = (name, (name, []): T);
   258 fun markup_string name prop = (name, fn s => (name, [(prop, s)]): T);
   259 fun markup_int name prop = (name, fn i => (name, [(prop, print_int i)]): T);
   260 
   261 
   262 (* misc properties *)
   263 
   264 val nameN = "name";
   265 fun name a = properties [(nameN, a)];
   266 
   267 val kindN = "kind";
   268 
   269 val instanceN = "instance";
   270 
   271 
   272 (* embedded languages *)
   273 
   274 val languageN = "language";
   275 val symbolsN = "symbols";
   276 val antiquotesN = "antiquotes";
   277 val delimitedN = "delimited"
   278 
   279 fun is_delimited props =
   280   Properties.get props delimitedN = SOME "true";
   281 
   282 fun language {name, symbols, antiquotes, delimited} =
   283   (languageN,
   284    [(nameN, name),
   285     (symbolsN, print_bool symbols),
   286     (antiquotesN, print_bool antiquotes),
   287     (delimitedN, print_bool delimited)]);
   288 
   289 fun language' {name, symbols, antiquotes} delimited =
   290   language {name = name, symbols = symbols, antiquotes = antiquotes, delimited = delimited};
   291 
   292 val language_method =
   293   language {name = "method", symbols = true, antiquotes = false, delimited = false};
   294 val language_attribute =
   295   language {name = "attribute", symbols = true, antiquotes = false, delimited = false};
   296 val language_sort = language' {name = "sort", symbols = true, antiquotes = false};
   297 val language_type = language' {name = "type", symbols = true, antiquotes = false};
   298 val language_term = language' {name = "term", symbols = true, antiquotes = false};
   299 val language_prop = language' {name = "prop", symbols = true, antiquotes = false};
   300 val language_ML = language' {name = "ML", symbols = false, antiquotes = true};
   301 val language_SML = language' {name = "SML", symbols = false, antiquotes = false};
   302 val language_document = language' {name = "document", symbols = false, antiquotes = true};
   303 val language_antiquotation =
   304   language {name = "antiquotation", symbols = true, antiquotes = false, delimited = true};
   305 val language_text = language' {name = "text", symbols = true, antiquotes = false};
   306 val language_rail = language {name = "rail", symbols = true, antiquotes = true, delimited = true};
   307 val language_path = language {name = "path", symbols = false, antiquotes = false, delimited = true};
   308 
   309 
   310 (* formal entities *)
   311 
   312 val (bindingN, binding) = markup_elem "binding";
   313 
   314 val entityN = "entity";
   315 fun entity kind name = (entityN, [(nameN, name), (kindN, kind)]);
   316 
   317 fun get_entity_kind (name, props) =
   318   if name = entityN then AList.lookup (op =) props kindN
   319   else NONE;
   320 
   321 val defN = "def";
   322 val refN = "ref";
   323 
   324 
   325 (* completion *)
   326 
   327 val (completionN, completion) = markup_elem "completion";
   328 val (no_completionN, no_completion) = markup_elem "no_completion";
   329 
   330 
   331 (* position *)
   332 
   333 val lineN = "line";
   334 val offsetN = "offset";
   335 val end_offsetN = "end_offset";
   336 val fileN = "file";
   337 val idN = "id";
   338 
   339 val position_properties' = [fileN, idN];
   340 val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
   341 
   342 val (positionN, position) = markup_elem "position";
   343 
   344 
   345 (* expression *)
   346 
   347 val (expressionN, expression) = markup_elem "expression";
   348 
   349 
   350 (* citation *)
   351 
   352 val (citationN, citation) = markup_string "citation" nameN;
   353 
   354 
   355 (* external resources *)
   356 
   357 val (pathN, path) = markup_string "path" nameN;
   358 val (urlN, url) = markup_string "url" nameN;
   359 
   360 
   361 (* pretty printing *)
   362 
   363 val indentN = "indent";
   364 val (blockN, block) = markup_int "block" indentN;
   365 
   366 val widthN = "width";
   367 val (breakN, break) = markup_int "break" widthN;
   368 
   369 val (fbreakN, fbreak) = markup_elem "fbreak";
   370 
   371 val (itemN, item) = markup_elem "item";
   372 
   373 
   374 (* text properties *)
   375 
   376 val (wordsN, words) = markup_elem "words";
   377 
   378 val (hiddenN, hidden) = markup_elem "hidden";
   379 
   380 
   381 (* misc entities *)
   382 
   383 val system_optionN = "system_option";
   384 
   385 val theoryN = "theory";
   386 val classN = "class";
   387 val type_nameN = "type_name";
   388 val constantN = "constant";
   389 
   390 val (fixedN, fixed) = markup_string "fixed" nameN;
   391 val (caseN, case_) = markup_string "case" nameN;
   392 val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN;
   393 
   394 val method_modifierN = "method_modifier";
   395 
   396 
   397 (* inner syntax *)
   398 
   399 val (tfreeN, tfree) = markup_elem "tfree";
   400 val (tvarN, tvar) = markup_elem "tvar";
   401 val (freeN, free) = markup_elem "free";
   402 val (skolemN, skolem) = markup_elem "skolem";
   403 val (boundN, bound) = markup_elem "bound";
   404 val (varN, var) = markup_elem "var";
   405 val (numeralN, numeral) = markup_elem "numeral";
   406 val (literalN, literal) = markup_elem "literal";
   407 val (delimiterN, delimiter) = markup_elem "delimiter";
   408 val (inner_stringN, inner_string) = markup_elem "inner_string";
   409 val (inner_cartoucheN, inner_cartouche) = markup_elem "inner_cartouche";
   410 val (inner_commentN, inner_comment) = markup_elem "inner_comment";
   411 
   412 val (token_rangeN, token_range) = markup_elem "token_range";
   413 
   414 val (sortingN, sorting) = markup_elem "sorting";
   415 val (typingN, typing) = markup_elem "typing";
   416 
   417 
   418 (* ML syntax *)
   419 
   420 val (ML_keyword1N, ML_keyword1) = markup_elem "ML_keyword1";
   421 val (ML_keyword2N, ML_keyword2) = markup_elem "ML_keyword2";
   422 val (ML_keyword3N, ML_keyword3) = markup_elem "ML_keyword3";
   423 val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
   424 val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
   425 val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
   426 val (ML_charN, ML_char) = markup_elem "ML_char";
   427 val (ML_stringN, ML_string) = markup_elem "ML_string";
   428 val (ML_commentN, ML_comment) = markup_elem "ML_comment";
   429 val (SML_stringN, SML_string) = markup_elem "SML_string";
   430 val (SML_commentN, SML_comment) = markup_elem "SML_comment";
   431 
   432 val ML_defN = "ML_def";
   433 val ML_openN = "ML_open";
   434 val ML_structureN = "ML_structure";
   435 val (ML_typingN, ML_typing) = markup_elem "ML_typing";
   436 
   437 
   438 (* antiquotations *)
   439 
   440 val (antiquotedN, antiquoted) = markup_elem "antiquoted";
   441 val (antiquoteN, antiquote) = markup_elem "antiquote";
   442 
   443 val ML_antiquotationN = "ML_antiquotation";
   444 val document_antiquotationN = "document_antiquotation";
   445 val document_antiquotation_optionN = "document_antiquotation_option";
   446 
   447 
   448 (* text structure *)
   449 
   450 val (paragraphN, paragraph) = markup_elem "paragraph";
   451 val (text_foldN, text_fold) = markup_elem "text_fold";
   452 
   453 
   454 (* outer syntax *)
   455 
   456 val (commandN, command) = markup_elem "command";
   457 val (keyword1N, keyword1) = markup_elem "keyword1";
   458 val (keyword2N, keyword2) = markup_elem "keyword2";
   459 val (keyword3N, keyword3) = markup_elem "keyword3";
   460 val (quasi_keywordN, quasi_keyword) = markup_elem "quasi_keyword";
   461 val (improperN, improper) = markup_elem "improper";
   462 val (operatorN, operator) = markup_elem "operator";
   463 val (stringN, string) = markup_elem "string";
   464 val (altstringN, altstring) = markup_elem "altstring";
   465 val (verbatimN, verbatim) = markup_elem "verbatim";
   466 val (cartoucheN, cartouche) = markup_elem "cartouche";
   467 val (commentN, comment) = markup_elem "comment";
   468 val (controlN, control) = markup_elem "control";
   469 
   470 val tokenN = "token";
   471 fun token delimited props = (tokenN, (delimitedN, print_bool delimited) :: props);
   472 
   473 
   474 (* timing *)
   475 
   476 val elapsedN = "elapsed";
   477 val cpuN = "cpu";
   478 val gcN = "gc";
   479 
   480 fun timing_properties {elapsed, cpu, gc} =
   481  [(elapsedN, Time.toString elapsed),
   482   (cpuN, Time.toString cpu),
   483   (gcN, Time.toString gc)];
   484 
   485 fun parse_timing_properties props =
   486  {elapsed = Properties.seconds props elapsedN,
   487   cpu = Properties.seconds props cpuN,
   488   gc = Properties.seconds props gcN};
   489 
   490 val timingN = "timing";
   491 fun timing t = (timingN, timing_properties t);
   492 
   493 
   494 (* command timing *)
   495 
   496 val command_timingN = "command_timing";
   497 
   498 fun command_timing_properties {file, offset, name} elapsed =
   499  [(fileN, file), (offsetN, print_int offset),
   500   (nameN, name), (elapsedN, Time.toString elapsed)];
   501 
   502 fun parse_command_timing_properties props =
   503   (case (Properties.get props fileN, Properties.get props offsetN, Properties.get props nameN) of
   504     (SOME file, SOME offset, SOME name) =>
   505       SOME ({file = file, offset = parse_int offset, name = name},
   506         Properties.seconds props elapsedN)
   507   | _ => NONE);
   508 
   509 
   510 (* toplevel *)
   511 
   512 val subgoalsN = "subgoals";
   513 val (proof_stateN, proof_state) = markup_int "proof_state" subgoalsN;
   514 
   515 val (stateN, state) = markup_elem "state";
   516 val (goalN, goal) = markup_elem "goal";
   517 val (subgoalN, subgoal) = markup_string "subgoal" nameN;
   518 
   519 
   520 (* command status *)
   521 
   522 val taskN = "task";
   523 
   524 val (acceptedN, accepted) = markup_elem "accepted";
   525 val (forkedN, forked) = markup_elem "forked";
   526 val (joinedN, joined) = markup_elem "joined";
   527 val (runningN, running) = markup_elem "running";
   528 val (finishedN, finished) = markup_elem "finished";
   529 val (failedN, failed) = markup_elem "failed";
   530 
   531 
   532 (* messages *)
   533 
   534 val serialN = "serial";
   535 fun serial_properties i = [(serialN, print_int i)];
   536 
   537 val exec_idN = "exec_id";
   538 
   539 val initN = "init";
   540 val statusN = "status";
   541 val resultN = "result";
   542 val writelnN = "writeln";
   543 val tracingN = "tracing";
   544 val warningN = "warning";
   545 val errorN = "error";
   546 val systemN = "system";
   547 val protocolN = "protocol";
   548 
   549 val (legacyN, legacy) = markup_elem "legacy";
   550 val (promptN, prompt) = markup_elem "prompt";
   551 
   552 val (reportN, report) = markup_elem "report";
   553 val (no_reportN, no_report) = markup_elem "no_report";
   554 
   555 val (badN, bad) = markup_elem "bad";
   556 
   557 val (intensifyN, intensify) = markup_elem "intensify";
   558 val (informationN, information) = markup_elem "information";
   559 
   560 
   561 (* active areas *)
   562 
   563 val browserN = "browser"
   564 val graphviewN = "graphview";
   565 
   566 val sendbackN = "sendback";
   567 val paddingN = "padding";
   568 val padding_line = (paddingN, "line");
   569 val padding_command = (paddingN, "command");
   570 
   571 val dialogN = "dialog";
   572 fun dialog i result = (dialogN, [(serialN, print_int i), (resultN, result)]);
   573 
   574 
   575 (* protocol message functions *)
   576 
   577 val functionN = "function"
   578 
   579 val assign_update = [(functionN, "assign_update")];
   580 val removed_versions = [(functionN, "removed_versions")];
   581 
   582 fun protocol_handler name = [(functionN, "protocol_handler"), (nameN, name)];
   583 
   584 fun invoke_scala name id = [(functionN, "invoke_scala"), (nameN, name), (idN, id)];
   585 fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
   586 
   587 val ML_statistics = (functionN, "ML_statistics");
   588 
   589 val task_statistics = (functionN, "task_statistics");
   590 
   591 val command_timing = (functionN, "command_timing");
   592 
   593 fun loading_theory name = [("function", "loading_theory"), ("name", name)];
   594 
   595 fun dest_loading_theory [("function", "loading_theory"), ("name", name)] = SOME name
   596   | dest_loading_theory _ = NONE;
   597 
   598 fun use_theories_result id ok =
   599   [("function", "use_theories_result"), ("id", id), ("ok", print_bool ok)];
   600 
   601 val print_operationsN = "print_operations";
   602 val print_operations = [(functionN, print_operationsN)];
   603 
   604 
   605 (* simplifier trace *)
   606 
   607 val simp_trace_panelN = "simp_trace_panel";
   608 
   609 val simp_trace_logN = "simp_trace_log";
   610 val simp_trace_stepN = "simp_trace_step";
   611 val simp_trace_recurseN = "simp_trace_recurse";
   612 val simp_trace_hintN = "simp_trace_hint";
   613 val simp_trace_ignoreN = "simp_trace_ignore";
   614 
   615 fun simp_trace_cancel i = [(functionN, "simp_trace_cancel"), (serialN, print_int i)];
   616 
   617 
   618 
   619 (** print mode operations **)
   620 
   621 val no_output = ("", "");
   622 fun default_output (_: T) = no_output;
   623 
   624 local
   625   val default = {output = default_output};
   626   val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default)]);
   627 in
   628   fun add_mode name output =
   629     Synchronized.change modes (fn tab =>
   630       (if not (Symtab.defined tab name) then ()
   631        else warning ("Redefining markup mode " ^ quote name);
   632        Symtab.update (name, {output = output}) tab));
   633   fun get_mode () =
   634     the_default default
   635       (Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ()));
   636 end;
   637 
   638 fun output m = if is_empty m then no_output else #output (get_mode ()) m;
   639 
   640 val enclose = output #-> Library.enclose;
   641 
   642 fun markup m =
   643   let val (bg, en) = output m
   644   in Library.enclose (Output.escape bg) (Output.escape en) end;
   645 
   646 fun markup_only m = markup m "";
   647 
   648 fun markup_report "" = ""
   649   | markup_report txt = markup report txt;
   650 
   651 end;