guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

54/66: programming-2022: Use BibTeX for bibliography; include DOI.


From: Ludovic Courtès
Subject: 54/66: programming-2022: Use BibTeX for bibliography; include DOI.
Date: Wed, 29 Jun 2022 11:32:04 -0400 (EDT)

civodul pushed a commit to branch master
in repository maintenance.

commit c0651347d20a5f9b3a3abf189646b366ec3accca
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Apr 28 15:27:49 2022 +0200

    programming-2022: Use BibTeX for bibliography; include DOI.
    
    * doc/programming-2022/bibliography.scm: New file.
    * doc/programming-2022/supply-chain.skb: Include it, and remove use of
    'references' from (skribilo packages acmproc).
---
 doc/programming-2022/bibliography.scm | 68 +++++++++++++++++++++++++++++++++++
 doc/programming-2022/supply-chain.skb |  7 +++-
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/doc/programming-2022/bibliography.scm 
b/doc/programming-2022/bibliography.scm
new file mode 100644
index 0000000..28d570c
--- /dev/null
+++ b/doc/programming-2022/bibliography.scm
@@ -0,0 +1,68 @@
+;; Bibliography via BibTeX.  Taken from (skribilo packages lncs).
+
+(define (bib-entry-template kind)
+  ;; Return a template for KIND that includes a DOI.
+  ;; Note: This uses the API of Skribilo 0.9.5 and earlier.
+  (let ((template (make-bib-entry-template/default kind)))
+    `(,@template (" DOI: " doi))))
+
+(when-engine-is-loaded 'latex
+  (lambda ()
+    (let ((latex (find-engine 'latex)))
+
+      ;; Use the native bibliography system (BibTeX).
+
+      (markup-writer 'bib-ref latex
+         :options '(:text :bib)
+         :action (lambda (n e)
+                   (let ((entry (handle-ast (markup-body n))))
+                     (format #t "\\cite{~a}" (markup-ident entry)))))
+
+      (markup-writer 'bib-ref+ latex
+         :options '(:text :bib :sort-bib-refs)
+         :action (lambda (n e)
+                   (let ((entries   (map (lambda (bib-ref)
+                                           (handle-ast (markup-body bib-ref)))
+                                         (markup-body n)))
+                         (sort-proc (markup-option n :sort-bib-refs)))
+                     (format #t "\\cite{~a}"
+                             (string-join (map markup-ident
+                                               (if (procedure? sort-proc)
+                                                   (sort entries sort-proc)
+                                                   entries))
+                                          ",")))))
+
+      (markup-writer '&the-bibliography latex
+         :before (lambda (n e)
+                   (let ((count (length (markup-body n))))
+                     (format #t "\\begin{thebibliography}{~a}\n"
+                             count)))
+         :after  "\\end{thebibliography}\n")
+
+      (markup-writer '&bib-entry-body
+         :action (lambda (n e)
+                   (let* ((kind (markup-option n 'kind))
+                          (template (bib-entry-template kind)))
+                     (output-bib-entry-template n e template))))
+
+      (markup-writer '&bib-entry latex
+         :action (lambda (n e)
+                   (display "%\n\\bibitem[")
+                   (output (markup-option n :title) e)
+                   (format #t "]{~a}\n" (markup-ident n))
+                   (output n e (markup-writer-get '&bib-entry-body e)))
+         :after "\n%\n")
+
+      ;; Journal and book titles must not be italicized.
+      (markup-writer '&bib-entry-booktitle latex
+         :action (lambda (n e)
+                   (let ((title (markup-body n)))
+                     (evaluate-document title e))))
+
+      (markup-writer '&bib-entry-journal latex
+         :action (lambda (n e)
+                   (evaluate-document (markup-body n) e))))))
+
+;;; Local Variables:
+;;; eval: (put 'markup-writer 'scheme-indent-function 2)
+;;; End:
diff --git a/doc/programming-2022/supply-chain.skb 
b/doc/programming-2022/supply-chain.skb
index 7259359..91b5486 100644
--- a/doc/programming-2022/supply-chain.skb
+++ b/doc/programming-2022/supply-chain.skb
@@ -8,6 +8,7 @@
             (skribilo lib)
             (skribilo evaluator)
             (skribilo biblio author)
+            (skribilo biblio template)
             (skribilo source)
             (skribilo source lisp)
             (skribilo source parameters)
@@ -145,6 +146,8 @@
 (define (acmart-abstract . body)
   (!latex "\\begin{abstract}\n$1\n\\end{abstract}\n" body))
 
+(include "bibliography.scm")
+
 (bibliography "../els-2013/guix.sbib")
 (bibliography "../reppar-2015/reppar.sbib")
 (bibliography "security.sbib")
@@ -1420,7 +1423,9 @@ possibly allowing users to register those when they first 
pull from the
 channel.  All this requires more thought, but it looks like there are
 new opportunities here.]))
    
-   (references))
+   (flush :side 'left
+     (the-bibliography
+      :sort bib-sort/first-author-last-name)))
    
 ;;; Local Variables:
 ;;; coding: utf-8



reply via email to

[Prev in Thread] Current Thread [Next in Thread]