Thanks to a decisive Hint by Frederic Tuong:

Managed to solve the Top-level-transaction problem
in “enriched_document_command”. Yay !!!
This commit is contained in:
Burkhart Wolff 2018-04-24 21:44:28 +02:00
parent b54ed35466
commit 0474c47957
2 changed files with 54 additions and 31 deletions

View File

@ -380,9 +380,11 @@ val attributes_upd =
val SPY = Unsynchronized.ref ([]:((term * Position.T) * term) list)
fun enriched_document_command markdown (((((oid,pos),cid_pos),doc_attrs),
xstring_opt:(xstring * Position.T) option),
toks:Input.source) =
toks:Input.source)
: Toplevel.transition -> Toplevel.transition =
let
val id = serial ();
val _ = Position.report pos (docref_markup true oid id pos);
@ -414,14 +416,10 @@ fun enriched_document_command markdown (((((oid,pos),cid_pos),doc_attrs),
id=id,
cid=cid_long})
end
fun MMM(SOME(s,p)) = SOME(s^"XXX",p)
|MMM(NONE) = SOME("XXX",Position.id "")
in
(Toplevel.theory(enrich_trans cid_pos)) #>
(Thy_Output.document_command markdown (MMM xstring_opt,toks)) #>
(Thy_Output.document_command markdown (SOME("\\label{"^oid^"}", Position.id ""),toks)) #>
(Thy_Output.document_command markdown (SOME("\\label{"^oid^"}", Position.id ""),toks))
fun check_text thy = (Thy_Output.output_text (Toplevel.theory_toplevel thy) markdown toks; thy)
in
Toplevel.theory(enrich_trans cid_pos #> check_text)
(* Thanks Frederic Tuong! ! ! *)
end;
@ -443,17 +441,18 @@ val _ =
val _ =
Outer_Syntax.command ("paragraph*", @{here}) "paragraph heading"
(attributes -- Parse.opt_target -- Parse.document_source --| semi
>> enriched_document_command {markdown = false});
>> enriched_document_command {markdown = true});
val _ =
Outer_Syntax.command ("subparagraph*", @{here}) "subparagraph heading"
(attributes -- Parse.opt_target -- Parse.document_source --| semi
>> enriched_document_command {markdown = false});
>> enriched_document_command {markdown = true});
val _ =
Outer_Syntax.command ("text*", @{here}) "formal comment (primary style)"
(attributes -- Parse.opt_target -- Parse.document_source
>> enriched_document_command {markdown = false});
>> enriched_document_command {markdown = true});
val _ =
Outer_Syntax.command @{command_keyword "declare_reference*"}
@ -647,19 +646,7 @@ val _ =
end (* struct *)
*}
ML{* open Mixfix*}
@ -673,15 +660,45 @@ ML{* (* Parsing combinators in Scan *)
Scan.repeat : ('a -> 'b * 'a) -> 'a -> 'b list * 'a;
Scan.option : ('a -> 'b * 'a) -> 'a -> 'b option * 'a;
*}
ML{* ignore *}
ML{*
Binding.print;
Syntax.read_sort;
Syntax.read_typ;
Syntax.read_term;
Syntax.pretty_typ;
Parse.document_source;
*}
ML{*
Thy_Output.output_text: Toplevel.state -> {markdown: bool} -> Input.source -> string;
Thy_Output.document_command;
Toplevel.exit: Toplevel.transition -> Toplevel.transition;
Toplevel.keep: (Toplevel.state -> unit) -> Toplevel.transition -> Toplevel.transition;
Toplevel.keep': (bool -> Toplevel.state -> unit) -> Toplevel.transition -> Toplevel.transition;
Toplevel.ignored: Position.T -> Toplevel.transition;
Toplevel.generic_theory: (generic_theory -> generic_theory) -> Toplevel.transition -> Toplevel.transition;
Toplevel.theory': (bool -> theory -> theory) -> Toplevel.transition -> Toplevel.transition;
Toplevel.theory: (theory -> theory) -> Toplevel.transition -> Toplevel.transition;
Toplevel.present_local_theory:
(xstring * Position.T) option ->
(Toplevel.state -> unit) -> Toplevel.transition -> Toplevel.transition;
(* where text treatment and antiquotation parsing happens *)
(*fun document_command markdown (loc, txt) =
Toplevel.keep (fn state =>
(case loc of
NONE => ignore (output_text state markdown txt)
| SOME (_, pos) =>
error ("Illegal target specification -- not a theory context" ^ Position.here pos))) o
Toplevel.present_local_theory loc (fn state => ignore (output_text state markdown txt)); *)
Thy_Output.document_command : {markdown: bool} -> (xstring * Position.T) option * Input.source ->
Toplevel.transition -> Toplevel.transition;
*}
ML\<open>
open Markup;
Markup.binding;
@ -696,7 +713,7 @@ Term_Style.parse;
Sign.certify_term;
\<close>
text {* Lq *}

View File

@ -10,7 +10,10 @@ text*[tit::title]{* Using The Isabelle Ontology Framework*}
text*[stit::subtitle] \<open>Linking the Formal with the Informal\<close>
text*[auth1::author, affiliation="''Universit\\'e Paris-Sud''"]\<open>Burkhart Wolff\<close>
text*[auth1::author, affiliation="''University of Sheffield''"]\<open>Achim Brucker\<close>
text*[auth2::author, affiliation="''Centrale-Supelec''"]\<open>Idir Ait-Adune\<close>
text*[auth3::author, affiliation="''IRT-SystemX''"]\<open>Paolo Crizzifulli\<close>
text*[auth4::author, affiliation="''Universit\\'e Paris-Sud''"]\<open>Burkhart Wolff\<close>
term "\<lparr>author.tag_attribute=undefined,affiliation=undefined\<rparr>"
ML{* !AnnoTextelemParser.SPY *}
@ -20,7 +23,7 @@ ML{*
val x = @{code "HURX"}
*}
definition HORX where "HORX = affiliation(\<lparr>author.tag_attribute=0,affiliation=undefined\<rparr>\<lparr>affiliation:='' ''\<rparr>) "
definition HORX where "HORX = affiliation(\<lparr>author.tag_attribute=0,affiliation=''''\<rparr>\<lparr>affiliation:=''e''\<rparr>) "
ML{*
val x = @{code "HORX"}
*}
@ -41,7 +44,7 @@ pretium consectetuer. Lectus accumsan velit ultrices, mauris amet, id elit aliqu
felis duis. Mattis molestie semper gravida in ullamcorper ut, id accumsan, fusce id
sed nibh ut lorem integer, maecenas sed mi purus non nunc, morbi pretium tortor.*}
section*[bgrnd::text_section]{* Background: Isabelle and Isabelle_DOF *}
section* [bgrnd :: text_section] {* Background: Isabelle and Isabelle_DOF *}
text{* As mentioned in @{introduction \<open>intro\<close>} ... *}
term "a + b = b + a"
@ -58,7 +61,10 @@ update_instance*[bgrnd, main_author = "Some(''bu'')", formula="@{term ''a + b =
section*[ontomod::technical]{* Modeling Ontologies in Isabelle_DOF *}
text{* Lorem ipsum dolor sit amet, suspendisse non arcu malesuada mollis, nibh morbi,*}
subsection*[scholar_onto::example]{* A Scholar Paper: Eating one's own dogfood. *}
text*[x]{* @{technical \<open>ontomod\<close>} *}
subsection*[scholar_onto::example]{* A Scholar Paper: Eating one's own dogfood. @{technical \<open>ontomod\<close>} *}
text{* @{technical \<open>ontomod\<close>}*}
subsection*[mathex_onto::example]{* Math-Exercise *}