Repaired output of marginal comments in ML antiquotation.
authorberghofe
Tue, 16 Dec 2008 17:37:39 +0100
changeset 57 065f472c09ab
parent 56 126646f2aa88
child 58 f3794c231898
Repaired output of marginal comments in ML antiquotation.
CookBook/Base.thy
CookBook/antiquote_setup.ML
CookBook/chunks.ML
cookbook.pdf
--- a/CookBook/Base.thy	Tue Dec 16 08:08:44 2008 +0000
+++ b/CookBook/Base.thy	Tue Dec 16 17:37:39 2008 +0100
@@ -1,8 +1,8 @@
 theory Base
 imports Main
 uses
+  "chunks.ML"
   "antiquote_setup.ML"
-  "chunks.ML"
 begin
 
 end
--- a/CookBook/antiquote_setup.ML	Tue Dec 16 08:08:44 2008 +0000
+++ b/CookBook/antiquote_setup.ML	Tue Dec 16 17:37:39 2008 +0100
@@ -22,9 +22,14 @@
 fun ml_struct txt = "functor DUMMY_FUNCTOR() = struct structure DUMMY = " ^ txt ^ " end";
 fun ml_type txt = "val _ = NONE : (" ^ txt ^ ") option";
 
+val transform_cmts_str =
+  Source.of_string #> ML_Lex.source #> Source.exhaust #>
+  Chunks.transform_cmts #> implode;
+
 fun output_ml ml src ctxt ((txt,ovars),pos) =
   (ML_Context.eval_in (SOME ctxt) false pos (ml ovars txt);
-  ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt (space_explode "\n" txt))
+   txt |> transform_cmts_str |> space_explode "\n" |>
+   ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt)
 
 fun output_ml_aux ml src ctxt (txt,pos) =
   output_ml (K ml) src ctxt ((txt,()),pos) 
--- a/CookBook/chunks.ML	Tue Dec 16 08:08:44 2008 +0000
+++ b/CookBook/chunks.ML	Tue Dec 16 17:37:39 2008 +0100
@@ -99,7 +99,7 @@
            Scan.repeat (Scan.unless (Scan.this_string "}*)")
              (Scan.one (not o Symbol.is_eof))) --|
            Scan.this_string "}*)" >>
-           (enclose "\\hfill\\textrm{\\textit{" "}}" o implode))
+           (Symbol.encode_raw o enclose "\\hfill\\textrm{\\textit{" "}}" o implode))
      || Scan.one not_eof >> ML_Lex.content_of)) #>
   fst;
 
@@ -124,10 +124,8 @@
           end)
     val txt = spc ^ implode (transform_cmts toks')
   in
-    ((if ! ThyOutput.source then str_of_source src else txt)
-    |> (if ! ThyOutput.quotes then quote else I)
-    |> (if ! ThyOutput.display then enclose "\\begin{alltt}\n" "\n\\end{alltt}"
-        else split_lines #> map verbatim #> space_implode "\\isasep\\isanewline%\n"))
+    txt |> split_lines |>
+    ThyOutput.output_list (fn _ => fn s => Pretty.str s) src ctxt
   end;
 
 val _ = ThyOutput.add_commands
Binary file cookbook.pdf has changed