139 for { |
139 for { |
140 s1 <- Library.try_unprefix("Running program \"", s) |
140 s1 <- Library.try_unprefix("Running program \"", s) |
141 s2 <- Library.try_unsuffix("\" ...", s1) |
141 s2 <- Library.try_unsuffix("\" ...", s1) |
142 } yield s2 |
142 } yield s2 |
143 |
143 |
144 sealed case class Document_Latex(name: Document.Node.Name, body: XML.Body) { |
144 sealed case class Document_Latex( |
|
145 name: Document.Node.Name, |
|
146 body: XML.Body, |
|
147 line_pos: Properties.T => Option[Int] |
|
148 ) { |
145 def content: File.Content_XML = File.content(Path.basic(tex_name(name)), body) |
149 def content: File.Content_XML = File.content(Path.basic(tex_name(name)), body) |
146 def file_pos: String = File.symbolic_path(name.path) |
150 def file_pos: String = File.symbolic_path(name.path) |
147 def write(latex_output: Latex.Output, dir: Path): Unit = |
151 def write(latex_output: Latex.Output, dir: Path): Unit = |
148 content.output(latex_output.make(_, file_pos = file_pos)).write(dir) |
152 content.output(latex_output.make(_, file_pos = file_pos, line_pos = line_pos)) |
|
153 .write(dir) |
149 } |
154 } |
150 |
155 |
151 def context( |
156 def context( |
152 session_context: Export.Session_Context, |
157 session_context: Export.Session_Context, |
153 document_session: Option[Sessions.Base] = None, |
158 document_session: Option[Sessions.Base] = None, |
232 if (document_selection(name)) { |
237 if (document_selection(name)) { |
233 val entry = session_context(name.theory, Export.DOCUMENT_LATEX, permissive = true) |
238 val entry = session_context(name.theory, Export.DOCUMENT_LATEX, permissive = true) |
234 YXML.parse_body(entry.text) |
239 YXML.parse_body(entry.text) |
235 } |
240 } |
236 else Nil |
241 else Nil |
237 Document_Latex(name, body) |
242 |
|
243 def line_pos(props: Properties.T): Option[Int] = |
|
244 Position.Line.unapply(props) orElse { |
|
245 for { |
|
246 snapshot <- session_context.document_snapshot |
|
247 id <- Position.Id.unapply(props) |
|
248 offset <- Position.Offset.unapply(props) |
|
249 pos <- snapshot.find_command_position(id, offset) |
|
250 } yield pos.line1 |
|
251 } |
|
252 |
|
253 Document_Latex(name, body, line_pos) |
238 } |
254 } |
239 |
255 |
240 |
256 |
241 /* build document */ |
257 /* build document */ |
242 |
258 |