241 |
241 |
242 fun document_antiq check ctxt (name, pos) = |
242 fun document_antiq check ctxt (name, pos) = |
243 let |
243 let |
244 val dir = master_directory (Proof_Context.theory_of ctxt); |
244 val dir = master_directory (Proof_Context.theory_of ctxt); |
245 val _ = check ctxt dir (name, pos); |
245 val _ = check ctxt dir (name, pos); |
246 in |
246 val latex = |
247 space_explode "/" name |
247 space_explode "/" name |
248 |> map Latex.output_ascii |
248 |> map Latex.output_ascii |
249 |> space_implode (Latex.output_ascii "/" ^ "\\discretionary{}{}{}") |
249 |> space_implode (Latex.output_ascii "/" ^ "\\discretionary{}{}{}"); |
250 |> enclose "\\isatt{" "}" |
250 in Latex.enclose_block "\\isatt{" "}" [Latex.string latex] end; |
251 end; |
|
252 |
251 |
253 fun ML_antiq check ctxt (name, pos) = |
252 fun ML_antiq check ctxt (name, pos) = |
254 let val path = check ctxt Path.current (name, pos); |
253 let val path = check ctxt Path.current (name, pos); |
255 in "Path.explode " ^ ML_Syntax.print_string (Path.implode path) end; |
254 in "Path.explode " ^ ML_Syntax.print_string (Path.implode path) end; |
256 |
255 |
257 in |
256 in |
258 |
257 |
259 val _ = Theory.setup |
258 val _ = Theory.setup |
260 (Document_Antiquotation.setup \<^binding>\<open>session\<close> (Scan.lift (Parse.position Parse.embedded)) |
259 (Thy_Output.antiquotation_verbatim \<^binding>\<open>session\<close> |
261 (fn {context = ctxt, ...} => Thy_Output.verbatim_text ctxt o check_session ctxt) #> |
260 (Scan.lift (Parse.position Parse.embedded)) check_session #> |
262 Document_Antiquotation.setup \<^binding>\<open>path\<close> (Scan.lift (Parse.position Parse.path)) |
261 Thy_Output.antiquotation_raw \<^binding>\<open>path\<close> |
263 (document_antiq check_path o #context) #> |
262 (Scan.lift (Parse.position Parse.path)) (document_antiq check_path) #> |
264 Document_Antiquotation.setup \<^binding>\<open>file\<close> (Scan.lift (Parse.position Parse.path)) |
263 Thy_Output.antiquotation_raw \<^binding>\<open>file\<close> |
265 (document_antiq check_file o #context) #> |
264 (Scan.lift (Parse.position Parse.path)) (document_antiq check_file) #> |
266 Document_Antiquotation.setup \<^binding>\<open>dir\<close> (Scan.lift (Parse.position Parse.path)) |
265 Thy_Output.antiquotation_raw \<^binding>\<open>dir\<close> |
267 (document_antiq check_dir o #context) #> |
266 (Scan.lift (Parse.position Parse.path)) (document_antiq check_dir) #> |
268 ML_Antiquotation.value \<^binding>\<open>path\<close> |
267 ML_Antiquotation.value \<^binding>\<open>path\<close> |
269 (Args.context -- Scan.lift (Parse.position Parse.path) >> uncurry (ML_antiq check_path)) #> |
268 (Args.context -- Scan.lift (Parse.position Parse.path) >> uncurry (ML_antiq check_path)) #> |
270 ML_Antiquotation.value \<^binding>\<open>file\<close> |
269 ML_Antiquotation.value \<^binding>\<open>file\<close> |
271 (Args.context -- Scan.lift (Parse.position Parse.path) >> uncurry (ML_antiq check_file)) #> |
270 (Args.context -- Scan.lift (Parse.position Parse.path) >> uncurry (ML_antiq check_file)) #> |
272 ML_Antiquotation.value \<^binding>\<open>dir\<close> |
271 ML_Antiquotation.value \<^binding>\<open>dir\<close> |