190 in (thy, present, size text) end; |
190 in (thy, present, size text) end; |
191 |
191 |
192 |
192 |
193 (* document antiquotation *) |
193 (* document antiquotation *) |
194 |
194 |
|
195 fun file_antiq do_check ctxt (name, pos) = |
|
196 let |
|
197 val dir = master_directory (Proof_Context.theory_of ctxt); |
|
198 val path = Path.append dir (Path.explode name); |
|
199 val _ = |
|
200 if not do_check orelse File.exists path then () |
|
201 else error ("Bad file: " ^ Path.print (Path.expand path) ^ Position.here pos); |
|
202 val _ = Position.report pos (Markup.path name); |
|
203 in |
|
204 space_explode "/" name |
|
205 |> map Thy_Output.verb_text |
|
206 |> space_implode (Thy_Output.verb_text "/" ^ "\\discretionary{}{}{}") |
|
207 end; |
|
208 |
195 val _ = Theory.setup |
209 val _ = Theory.setup |
196 (Thy_Output.antiquotation (Binding.name "file") (Scan.lift (Parse.position Parse.path)) |
210 (Thy_Output.antiquotation (Binding.name "file") (Scan.lift (Parse.position Parse.path)) |
197 (fn {context = ctxt, ...} => fn (name, pos) => |
211 (file_antiq true o #context) #> |
198 let |
212 (Thy_Output.antiquotation (Binding.name "file_unchecked") (Scan.lift (Parse.position Parse.path)) |
199 val dir = master_directory (Proof_Context.theory_of ctxt); |
213 (file_antiq false o #context))); |
200 val path = Path.append dir (Path.explode name); |
|
201 val _ = |
|
202 if File.exists path then () |
|
203 else error ("Bad file: " ^ Path.print (Path.expand path) ^ Position.here pos); |
|
204 val _ = Position.report pos (Markup.path name); |
|
205 in |
|
206 space_explode "/" name |
|
207 |> map Thy_Output.verb_text |
|
208 |> space_implode (Thy_Output.verb_text "/" ^ "\\discretionary{}{}{}") |
|
209 end)); |
|
210 |
214 |
211 end; |
215 end; |