src/Pure/Thy/document_build.scala
changeset 77173 f1063cdb0093
parent 77025 34219d664854
child 77174 1eb55d6809b3
equal deleted inserted replaced
77172:816959264c32 77173:f1063cdb0093
   130 
   130 
   131   val isabelle_styles: List[Path] =
   131   val isabelle_styles: List[Path] =
   132     List("isabelle.sty", "isabellesym.sty", "pdfsetup.sty", "railsetup.sty").
   132     List("isabelle.sty", "isabellesym.sty", "pdfsetup.sty", "railsetup.sty").
   133       map(name => texinputs + Path.basic(name))
   133       map(name => texinputs + Path.basic(name))
   134 
   134 
   135   def running_script(title: String): String =
   135   def program_start(title: String): String =
   136     "echo " + Bash.string("Running program \"" + title + "\" ...") + ";"
   136     "PROGRAM START \"" + title + "\" ..."
   137 
   137 
   138   def detect_running_script(s: String): Option[String] =
   138   def program_start_script(title: String): String =
       
   139     "echo " + Bash.string(program_start(title)) + ";"
       
   140 
       
   141   def detect_program_start(s: String): Option[String] =
   139     for {
   142     for {
   140       s1 <- Library.try_unprefix("Running program \"", s)
   143       s1 <- Library.try_unprefix("PROGRAM START \"", s)
   141       s2 <- Library.try_unsuffix("\" ...", s1)
   144       s2 <- Library.try_unsuffix("\" ...", s1)
   142     } yield s2
   145     } yield s2
   143 
   146 
   144   sealed case class Document_Latex(
   147   sealed case class Document_Latex(
   145     name: Document.Node.Name,
   148     name: Document.Node.Name,
   343     def conditional_script(
   346     def conditional_script(
   344       ext: String, exe: String, title: String = "", after: String = ""
   347       ext: String, exe: String, title: String = "", after: String = ""
   345     ): String = {
   348     ): String = {
   346       "if [ -f " + root_name_script(ext) + " ]\n" +
   349       "if [ -f " + root_name_script(ext) + " ]\n" +
   347       "then\n" +
   350       "then\n" +
   348       "  " + (if (title.nonEmpty) running_script(title) else "") +
   351       "  " + (if (title.nonEmpty) program_start_script(title) else "") +
   349         exe + " " + root_name_script() + "\n" +
   352         exe + " " + root_name_script() + "\n" +
   350       (if (after.isEmpty) "" else "  " + after) +
   353       (if (after.isEmpty) "" else "  " + after) +
   351       "fi\n"
   354       "fi\n"
   352     }
   355     }
   353 
   356 
   388   abstract class Bash_Engine(name: String) extends Engine(name) {
   391   abstract class Bash_Engine(name: String) extends Engine(name) {
   389     def prepare_directory(context: Context, dir: Path, doc: Document_Variant): Directory =
   392     def prepare_directory(context: Context, dir: Path, doc: Document_Variant): Directory =
   390       context.prepare_directory(dir, doc, new Latex.Output(context.options))
   393       context.prepare_directory(dir, doc, new Latex.Output(context.options))
   391 
   394 
   392     def use_pdflatex: Boolean = false
   395     def use_pdflatex: Boolean = false
   393     def running_latex: String = running_script(if (use_pdflatex) "pdflatex" else "lualatex")
   396     def start_latex: String = program_start_script(if (use_pdflatex) "pdflatex" else "lualatex")
   394     def latex_script(context: Context, directory: Directory): String =
   397     def latex_script(context: Context, directory: Directory): String =
   395       running_latex + (if (use_pdflatex) "$ISABELLE_PDFLATEX" else "$ISABELLE_LUALATEX") +
   398       start_latex + (if (use_pdflatex) "$ISABELLE_PDFLATEX" else "$ISABELLE_LUALATEX") +
   396         " " + directory.root_name_script() + "\n"
   399         " " + directory.root_name_script() + "\n"
   397 
   400 
   398     def bibtex_script(context: Context, directory: Directory, latex: Boolean = false): String = {
   401     def bibtex_script(context: Context, directory: Directory, latex: Boolean = false): String = {
   399       val ext = if (context.document_bibliography) "aux" else "bib"
   402       val ext = if (context.document_bibliography) "aux" else "bib"
   400       directory.conditional_script(ext, "$ISABELLE_BIBTEX", title = "bibtex",
   403       directory.conditional_script(ext, "$ISABELLE_BIBTEX", title = "bibtex",