proper citations for unselected theories, notably for the default selection of the GUI panel;
authorwenzelm
Fri, 20 Jan 2023 13:42:39 +0100
changeset 77025 34219d664854
parent 77024 6e90e84f7e7c
child 77026 808412ec2e13
proper citations for unselected theories, notably for the default selection of the GUI panel;
src/Pure/Thy/bibtex.scala
src/Pure/Thy/document_build.scala
--- a/src/Pure/Thy/bibtex.scala	Fri Jan 20 13:31:58 2023 +0100
+++ b/src/Pure/Thy/bibtex.scala	Fri Jan 20 13:42:39 2023 +0100
@@ -748,6 +748,13 @@
     sealed case class Inner(kind: String, citations: String, location: XML.Body, pos: Position.T) {
       def nocite: Inner = copy(kind = NOCITE, location = Nil)
 
+      def latex_text: Latex.Text = {
+        val props =
+          (if (kind.nonEmpty) Markup.Kind(kind) else Nil) :::
+          Markup.Citations(citations) ::: pos
+        List(XML.Elem(Markup.Latex_Cite(props), location))
+      }
+
       override def toString: String = citations
     }
 
--- a/src/Pure/Thy/document_build.scala	Fri Jan 20 13:31:58 2023 +0100
+++ b/src/Pure/Thy/document_build.scala	Fri Jan 20 13:42:39 2023 +0100
@@ -240,7 +240,15 @@
             val entry = session_context(name.theory, Export.DOCUMENT_LATEX, permissive = true)
             YXML.parse_body(entry.text)
           }
-          else Nil
+          else {
+            val text =
+              proper_string(session_context.theory_source(name.theory)) getOrElse
+                File.read(name.path)
+            (for {
+              outer <- Bibtex.Cite.parse(Bibtex.cite_commands(options), text)
+              inner <- outer.parse
+            } yield inner.nocite.latex_text).flatten
+          }
 
         def line_pos(props: Properties.T): Option[Int] =
           Position.Line.unapply(props) orElse {