src/Pure/Tools/bibtex.ML
author wenzelm
Fri, 17 Apr 2015 22:15:35 +0200
changeset 60125 2944cc4f4f56
parent 58550 f65911a725ba
child 65032 42b92fa72a51
permissions -rw-r--r--
tuned spelling;

(*  Title:      Pure/Tools/bibtex.ML
    Author:     Makarius

BibTeX support.
*)

signature BIBTEX =
sig
  val cite_macro: string Config.T
end;

structure Bibtex: BIBTEX =
struct

val cite_macro = Attrib.setup_config_string @{binding cite_macro} (K "cite");

val _ =
  Theory.setup
   (Thy_Output.add_option @{binding cite_macro} (Config.put cite_macro) #>
    Thy_Output.antiquotation @{binding cite}
      (Scan.lift
        (Scan.option (Parse.verbatim || Parse.cartouche) --
         Parse.and_list1 (Parse.position Args.name)))
      (fn {context = ctxt, ...} => fn (opt, citations) =>
        let
          val _ =
            Context_Position.reports ctxt
              (map (fn (name, pos) => (pos, Markup.citation name)) citations);
          val opt_arg = (case opt of NONE => "" | SOME s => "[" ^ s ^ "]");
          val arg = "{" ^ space_implode "," (map #1 citations) ^ "}";
        in "\\" ^ Config.get ctxt cite_macro ^ opt_arg ^ arg end));

end;