src/Pure/Tools/bibtex.scala
changeset 67248 68177abb2988
parent 67243 6a93aaa3ed36
child 67250 6c837185aa61
equal deleted inserted replaced
67247:3a9651318015 67248:68177abb2988
   501       "paragraph" -> "html-n",
   501       "paragraph" -> "html-n",
   502       "unsort" -> "html-u",
   502       "unsort" -> "html-u",
   503       "unsortlist" -> "html-u")
   503       "unsortlist" -> "html-u")
   504 
   504 
   505   def html_output(bib: List[Path],
   505   def html_output(bib: List[Path],
       
   506     body: Boolean = false,
   506     citations: List[String] = List("*"),
   507     citations: List[String] = List("*"),
   507     style: String = "empty",
   508     style: String = "empty",
   508     chronological: Boolean = false): String =
   509     chronological: Boolean = false): String =
   509   {
   510   {
   510     Isabelle_System.with_tmp_dir("bibtex")(tmp_dir =>
   511     Isabelle_System.with_tmp_dir("bibtex")(tmp_dir =>
   551           File.bash_path(in_file) + " " + File.bash_path(out_file),
   552           File.bash_path(in_file) + " " + File.bash_path(out_file),
   552         cwd = tmp_dir.file).check
   553         cwd = tmp_dir.file).check
   553 
   554 
   554       val html = File.read(tmp_dir + out_file)
   555       val html = File.read(tmp_dir + out_file)
   555 
   556 
   556       cat_lines(
   557       if (body) {
   557         split_lines(html).
   558         cat_lines(
   558           dropWhile(line => !line.startsWith("<!-- BEGIN BIBLIOGRAPHY")).reverse.
   559           split_lines(html).
   559           dropWhile(line => !line.startsWith("<!-- END BIBLIOGRAPHY")).reverse)
   560             dropWhile(line => !line.startsWith("<!-- BEGIN BIBLIOGRAPHY")).reverse.
       
   561             dropWhile(line => !line.startsWith("<!-- END BIBLIOGRAPHY")).reverse)
       
   562       }
       
   563       else html
   560     })
   564     })
   561   }
   565   }
       
   566 
       
   567   def present(snapshot: Document.Snapshot): String =
       
   568   {
       
   569     Isabelle_System.with_tmp_file("bib", "bib") { bib =>
       
   570       File.write(bib, snapshot.node.get_text)
       
   571       html_output(List(bib), style = "unsortlist")
       
   572     }
       
   573   }
   562 }
   574 }