From c1510c6f5c2f65177b2b92878f9d9752a436b65c Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sun, 13 Sep 2026 16:33:28 -0400 Subject: [PATCH 1/9] autobib: include "." after doi, to clearly separate from notes. Much improves the bibliography for my book LtUO. --- scribble-lib/scriblib/autobib.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index 92674a2315..aebb94bbcc 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -421,7 +421,7 @@ ".") null) (if (and (not doi) url) `(" " ,[(url-rendering) url]) null) - (if doi `(" " ,[(doi-rendering) doi]) null) + (if doi `(" " ,[(doi-rendering) doi] ".") null) (if note `(" " ,note) null)))) (define-syntax (define-cite stx) From 1c3d59b3ba88252ff81ffc50b46f3a5d5fbd29c2 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Mon, 14 Sep 2026 02:26:25 -0400 Subject: [PATCH 2/9] Update test --- scribble-test/tests/scriblib/bibtex.latex-escapes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scribble-test/tests/scriblib/bibtex.latex-escapes.txt b/scribble-test/tests/scriblib/bibtex.latex-escapes.txt index 838181d2c0..5fb75edc8d 100644 --- a/scribble-test/tests/scriblib/bibtex.latex-escapes.txt +++ b/scribble-test/tests/scriblib/bibtex.latex-escapes.txt @@ -4,4 +4,4 @@ Bibliography Yovine. Parametric prediction of heap memory requirements. In Proc. Proceedings of the 7th international symposium on Memory management, ISMM ’08, pp. 141–150. ACM, New York, NY, USA, 2008. - doi:10.1145/1375634.1375655 + doi:10.1145/1375634.1375655. From ce4e0926a2c0c0d862d0d11000c08990dad3e813 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Fri, 18 Sep 2026 16:27:41 -0400 Subject: [PATCH 3/9] autobib.tex: use \Needspace instead of \parbox --- scribble-lib/scriblib/autobib.tex | 43 +++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/scribble-lib/scriblib/autobib.tex b/scribble-lib/scriblib/autobib.tex index 8e95ce9711..7cac87a596 100644 --- a/scribble-lib/scriblib/autobib.tex +++ b/scribble-lib/scriblib/autobib.tex @@ -1,12 +1,45 @@ +\usepackage{needspace} +\usepackage{calc} + +\newenvironment{AutoBibliography} + {\begin{small}} + {\end{small}} + +% Minimum space required before starting a bibliography entry. +% Evaluated where it is used, so \baselineskip is that of AutoBibliography +% (i.e. \small). +\newcommand{\AutobibNeedspace}{5\baselineskip} + +% Indentation of continuation lines and subsequent paragraphs. +\newlength{\ABindent} +\setlength{\ABindent}{0.05\linewidth} + +\newcommand{\AutobibParindent}{1.5em} + +\newcommand{\Autobibentry}[1]{% + \par + \Needspace{\AutobibNeedspace}% + \begingroup + \emergencystretch=2em + \tolerance=1000 + \leftskip=\ABindent + \parindent=\AutobibParindent + \noindent + \hspace*{-\ABindent}% + #1% + \par + \endgroup + \addvspace{1.0ex}% +} -\newenvironment{AutoBibliography}{\begin{small}}{\end{small}} -\newcommand{\Autobibentry}[1]{\hspace{0.05\linewidth}\parbox[t]{0.95\linewidth}{\parindent=-0.05\linewidth#1\vspace{1.0ex}}} \newcommand{\Autobibtarget}[1]{\phantomsection#1} -\usepackage{calc} \newlength{\ABcollength} -\newcommand{\Autocolbibnumber}[1]{\parbox[t]{5ex}{\hfill#1~~\vspace{1.0ex}}} -\newcommand{\Autocolbibentry}[1]{\setlength{\ABcollength}{\linewidth-5ex}\parbox[t]{\ABcollength}{#1\vspace{1.0ex}}} +\newcommand{\Autocolbibnumber}[1]{% + \parbox[t]{5ex}{\hfill#1~~\vspace{1.0ex}}} +\newcommand{\Autocolbibentry}[1]{% + \setlength{\ABcollength}{\linewidth-5ex}% + \parbox[t]{\ABcollength}{#1\vspace{1.0ex}}} \newcommand{\Autobibref}[1]{#1} From 46d4b7dc1f1ff85b04257c2d0787a3befb2496fd Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 12:20:14 -0400 Subject: [PATCH 4/9] Only add "." after doi if there's a note afterwards. --- scribble-lib/scriblib/autobib.rkt | 2 +- scribble-test/tests/scriblib/bibtex.latex-escapes.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index aebb94bbcc..d189ec3105 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -421,7 +421,7 @@ ".") null) (if (and (not doi) url) `(" " ,[(url-rendering) url]) null) - (if doi `(" " ,[(doi-rendering) doi] ".") null) + (if doi `(" " ,[(doi-rendering) doi] ,(if note "." null)) null) (if note `(" " ,note) null)))) (define-syntax (define-cite stx) diff --git a/scribble-test/tests/scriblib/bibtex.latex-escapes.txt b/scribble-test/tests/scriblib/bibtex.latex-escapes.txt index 5fb75edc8d..838181d2c0 100644 --- a/scribble-test/tests/scriblib/bibtex.latex-escapes.txt +++ b/scribble-test/tests/scriblib/bibtex.latex-escapes.txt @@ -4,4 +4,4 @@ Bibliography Yovine. Parametric prediction of heap memory requirements. In Proc. Proceedings of the 7th international symposium on Memory management, ISMM ’08, pp. 141–150. ACM, New York, NY, USA, 2008. - doi:10.1145/1375634.1375655. + doi:10.1145/1375634.1375655 From 3499e151b2fd7a079a99c3c5b47b16e9f64f1217 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 19:16:30 -0400 Subject: [PATCH 5/9] Make autobib more accepting of content in some fields (vs strings) --- scribble-lib/scriblib/autobib.rkt | 93 ++++++++++++++++++------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index d189ec3105..8fec45bfa8 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -540,11 +540,22 @@ (define (given-names->initials str) (regexp-replace* #rx"(.)[^ ]*( |$)" str "\\1. ")) +;; return content for v, or false +(define (contentify v) + (and v (if (content? v) v (format "~a" v)))) +;; return string for v, or false +(define (stringify v) + (and v (cond [(string? v) v] + [(content? v) (content->string v)] + [else (format "~a" v)]))) + (module+ test (require rackunit) (check-equal? (given-names->initials "Matthew") "M. ") (check-equal? (given-names->initials "Matthew R.") "M. R. ") - (check-equal? (given-names->initials "Matthew Raymond") "M. R. ")) + (check-equal? (given-names->initials "Matthew Raymond") "M. R. ") + (check-equal? (content->string (journal-location (bold "Journal of Things"))) "Journal of Things") + (check-equal? (content->string (author-name (italic "Ada") "Lovelace")) "Ada Lovelace")) (define (proceedings-location #:editor [editor_ #f] @@ -562,7 +573,7 @@ (concatenate-elements #:separator ", " (and editor_ (editor editor_)) - @italic{@elem{Proc. @to-string[location]}} + @italic{@elem{Proc. @contentify[location]}} (series-volume-number-pages-element series volume number pages))) #:separator ". " (organization-publisher-address-element organization publisher address))) @@ -573,7 +584,7 @@ #:number [number #f] #:pages [pages #f]) (concatenate-elements - @italic{@to-string[location]} + @italic{@contentify[location]} #:separator " " (series-volume-number-pages-element #f volume number pages))) @@ -582,7 +593,7 @@ (concatenate-elements (and url ((url-rendering) url)) #:separator " " - (and accessed @elem{(accessed @to-string[accessed])}))) + (and accessed @elem{(accessed @contentify[accessed])}))) (define (string-capitalize str) (if (non-empty-string? str) @@ -611,7 +622,7 @@ (concatenate-elements #:separator ", " (edition-element edition) - (to-string* chapter) + (contentify chapter) (and editor_ (editor editor_)) (series-volume-number-pages-element series volume number pages)) #:separator ". " @@ -621,12 +632,12 @@ #:howpublished [howpublished #f] #:address [address #f]) (concatenate-elements #:separator ". " - (to-string* howpublished) - (to-string* address))) + (contentify howpublished) + (contentify address))) (define (misc-location #:howpublished [howpublished #f]) - (and howpublished (elem (to-string howpublished)))) + (and howpublished (elem (contentify howpublished)))) (define (manual-location #:organization [organization #f] @@ -634,7 +645,7 @@ (concatenate-elements (edition-element edition) #:separator ", " - (to-string* organization))) + (contentify organization))) (define (techrpt-location #:institution institution @@ -642,7 +653,7 @@ #:number [number #f] #:address [address #f]) (concatenate-elements #:separator ", " - (to-string* institution) (to-string* type) (to-string* number) (to-string* address))) + (contentify institution) (contentify type) (contentify number) (contentify address))) (define (dissertation-location #:institution institution @@ -650,10 +661,10 @@ #:type [type #f] #:address [address #f]) (concatenate-elements #:separator ", " - @elem{@to-string[degree] dissertation} - (to-string institution) - (to-string* type) - (to-string* address))) + @elem{@contentify[degree] dissertation} + (contentify institution) + (contentify type) + (contentify address))) (define (book-chapter-location location @@ -667,7 +678,7 @@ #:publisher [publisher #f] #:address [address #f]) (concatenate-elements #:separator " " - @elem{In @italic{@elem{@to-string[location]}}} + @elem{In @italic{@elem{@contentify[location]}}} (book-location #:edition edition #:chapter chapter #:editor editor_ #:series series #:volume volume #:number number #:pages pages #:publisher publisher #:address address))) @@ -675,21 +686,28 @@ ;; ---------------------------------------- (define (author-name first last #:suffix [suffix #f]) + (define first* (contentify first)) + (define last* (contentify last)) + (define suffix* (contentify suffix)) + + ;; Plain-text projections are needed for sorting. + (define first-string (stringify first)) + (define last-string (stringify last)) + (define suffix-string (stringify suffix)) (make-author-element #f - (list - (format "~a ~a~a" - (if (abbreviate-given-names) - (given-names->initials first) - first) - last - (if suffix - (format " ~a" suffix) - ""))) - (format "~a ~a~a" last first (if suffix - (format " ~a" suffix) - "")) - last)) + (append + (list (if (abbreviate-given-names) + (given-names->initials first-string) + first*) + " " + last*) + (if suffix* + (list " " suffix*) + null)) + (format "~a ~a~a" last-string first-string + (if suffix-string (format " ~a" suffix-string) "")) + last*)) (define (org-author-name org) (make-author-element @@ -749,25 +767,24 @@ (author-element-names name) (author-element-cite name)))) -(define (to-string v) (format "~a" v)) -(define (to-string* v) (and v (to-string v))) (define (edition-element edition) - (and edition @elem{@(string-capitalize (to-string edition)) edition})) + (and edition + @elem{@(string-capitalize (stringify edition)) edition})) (define (pages-element pages) - (and pages @elem{pp. @(to-string (car pages))--@(to-string (cadr pages))})) + (and pages @elem{pp. @(contentify (car pages))--@(contentify (cadr pages))})) (define (series-volume-number-pages-element series volume number pages) (concatenate-elements - (to-string* series) + (contentify series) #:separator ", " (concatenate-elements - (to-string* volume) - (and number @elem{(@to-string[number])})) + (contentify volume) + (and number @elem{(@contentify[number])})) (pages-element pages))) (define (organization-publisher-address-element organization publisher address) (concatenate-elements - (to-string* organization) + (contentify organization) #:separator ". " (concatenate-elements - (to-string* publisher) + (contentify publisher) #:separator ", " - (to-string* address)))) + (contentify address)))) From f3d57f21a7fe505c7e3a19ed624bfc37f654581d Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 20:50:13 -0400 Subject: [PATCH 6/9] autobib.rkt: more tweaks and tests --- scribble-lib/scriblib/autobib.rkt | 52 ++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index 8fec45bfa8..512aae974b 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -540,14 +540,14 @@ (define (given-names->initials str) (regexp-replace* #rx"(.)[^ ]*( |$)" str "\\1. ")) -;; return content for v, or false +;; return content for v, preserve false (define (contentify v) - (and v (if (content? v) v (format "~a" v)))) -;; return string for v, or false + (if (or (not v) (content? v) (string? v)) + v + (format "~a" v))) +;; return string for v, preserve false (define (stringify v) - (and v (cond [(string? v) v] - [(content? v) (content->string v)] - [else (format "~a" v)]))) + (and v (content->string v))) (module+ test (require rackunit) @@ -555,7 +555,45 @@ (check-equal? (given-names->initials "Matthew R.") "M. R. ") (check-equal? (given-names->initials "Matthew Raymond") "M. R. ") (check-equal? (content->string (journal-location (bold "Journal of Things"))) "Journal of Things") - (check-equal? (content->string (author-name (italic "Ada") "Lovelace")) "Ada Lovelace")) + (check-equal? (content->string (author-name (italic "Ada") "Lovelace")) "Ada Lovelace") + + (check-false (contentify #f)) + (check-false (stringify #f)) + (check-equal? (contentify 42) "42") + (check-equal? (stringify 42) "42") + (define emphasized (italic "foo")) + (check-eq? (contentify emphasized) emphasized) + (check-equal? (stringify emphasized) "foo") + + (define no-note + (make-bib #:title "Title" #:doi "10.1234/foo")) + (define with-note + (make-bib #:title "Title" + #:doi "10.1234/foo" + #:note "A note")) + (check-equal? + (content->string + (bib->entry no-note author+date-style #f + default-render-date-bib 1)) + "Title. doi:10.1234/foo") + (check-equal? + (content->string + (bib->entry with-note author+date-style #f + default-render-date-bib 1)) + "Title. doi:10.1234/foo. A note") + + (check-equal? + (content->string + (book-location + #:edition "second" + #:chapter 3 + #:series "LNCS" + #:volume 42 + #:number 7 + #:pages '(10 20) + #:publisher "Springer" + #:address "Berlin")) + "Second edition, 3, LNCS, 42(7), pp. 10--20. Springer, Berlin")) (define (proceedings-location #:editor [editor_ #f] From 0dad06b544fff5097ef28369af4c00b1a2532608 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 20:50:23 -0400 Subject: [PATCH 7/9] autobib.tex: also convert numbered bibliographies from parbox to needspace --- scribble-lib/scriblib/autobib.tex | 44 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/scribble-lib/scriblib/autobib.tex b/scribble-lib/scriblib/autobib.tex index 7cac87a596..9d692141cd 100644 --- a/scribble-lib/scriblib/autobib.tex +++ b/scribble-lib/scriblib/autobib.tex @@ -1,24 +1,28 @@ \usepackage{needspace} -\usepackage{calc} \newenvironment{AutoBibliography} {\begin{small}} {\end{small}} -% Minimum space required before starting a bibliography entry. -% Evaluated where it is used, so \baselineskip is that of AutoBibliography -% (i.e. \small). -\newcommand{\AutobibNeedspace}{5\baselineskip} +% Minimum number of lines that must remain before starting an entry. +\newcount\AutobibNeedlines +\AutobibNeedlines=5 -% Indentation of continuation lines and subsequent paragraphs. +% Hanging indentation of ordinary bibliography entries. \newlength{\ABindent} \setlength{\ABindent}{0.05\linewidth} -\newcommand{\AutobibParindent}{1.5em} +% Additional indentation of subsequent paragraph first lines. +\newlength{\AutobibParindent} +\setlength{\AutobibParindent}{1.5em} + +% Width reserved for the number in a numbered bibliography. +\newlength{\AutobibNumberWidth} +\setlength{\AutobibNumberWidth}{5ex} \newcommand{\Autobibentry}[1]{% \par - \Needspace{\AutobibNeedspace}% + \Needspace{\AutobibNeedlines\baselineskip}% \begingroup \emergencystretch=2em \tolerance=1000 @@ -33,16 +37,26 @@ } \newcommand{\Autobibtarget}[1]{\phantomsection#1} - -\newlength{\ABcollength} \newcommand{\Autocolbibnumber}[1]{% - \parbox[t]{5ex}{\hfill#1~~\vspace{1.0ex}}} + \par + \Needspace{\AutobibNeedlines\baselineskip}% + \begingroup + \emergencystretch=2em + \tolerance=1000 + \leftskip=\AutobibNumberWidth + \parindent=\AutobibParindent + \noindent + \hspace*{-\AutobibNumberWidth}% + \makebox[\AutobibNumberWidth][r]{#1~~}% + \ignorespaces +} \newcommand{\Autocolbibentry}[1]{% - \setlength{\ABcollength}{\linewidth-5ex}% - \parbox[t]{\ABcollength}{#1\vspace{1.0ex}}} - + #1% + \par + \endgroup + \addvspace{1.0ex}% +} \newcommand{\Autobibref}[1]{#1} - \providecommand{\AutobibLink}[1]{#1} \newcommand{\pseudodoi}[1]{#1} From 4f0ee35ca3b03f272a0fc8b41aaa0d32ca45cae0 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 22:34:58 -0400 Subject: [PATCH 8/9] autobib: fix some issues I introduced --- scribble-lib/scriblib/autobib.rkt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index 512aae974b..ec31e78859 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -611,7 +611,7 @@ (concatenate-elements #:separator ", " (and editor_ (editor editor_)) - @italic{@elem{Proc. @contentify[location]}} + (and location @italic{@elem{Proc. @contentify[location]}}) (series-volume-number-pages-element series volume number pages))) #:separator ". " (organization-publisher-address-element organization publisher address))) @@ -622,7 +622,7 @@ #:number [number #f] #:pages [pages #f]) (concatenate-elements - @italic{@contentify[location]} + (and location @italic{@contentify[location]}) #:separator " " (series-volume-number-pages-element #f volume number pages))) @@ -716,7 +716,7 @@ #:publisher [publisher #f] #:address [address #f]) (concatenate-elements #:separator " " - @elem{In @italic{@elem{@contentify[location]}}} + (and location @elem{In @italic{@elem{@contentify[location]}}}) (book-location #:edition edition #:chapter chapter #:editor editor_ #:series series #:volume volume #:number number #:pages pages #:publisher publisher #:address address))) @@ -734,15 +734,12 @@ (define suffix-string (stringify suffix)) (make-author-element #f - (append - (list (if (abbreviate-given-names) + (concatenate-elements #:separator " " + (if (abbreviate-given-names) (given-names->initials first-string) first*) - " " - last*) - (if suffix* - (list " " suffix*) - null)) + last* + suffix*) (format "~a ~a~a" last-string first-string (if suffix-string (format " ~a" suffix-string) "")) last*)) From 0528513b9a02dba9d5e1f48130590a899e82df38 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau Date: Sat, 19 Sep 2026 23:04:29 -0400 Subject: [PATCH 9/9] bibtex: be stricter for proceedings location --- scribble-lib/scriblib/bibtex.rkt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scribble-lib/scriblib/bibtex.rkt b/scribble-lib/scriblib/bibtex.rkt index 7bedc96f69..9d44217bdf 100644 --- a/scribble-lib/scriblib/bibtex.rkt +++ b/scribble-lib/scriblib/bibtex.rkt @@ -540,7 +540,7 @@ #:title (support-escapes (raw-attr "title")) #:date (raw-attr "year") ;; TODO: optional month #:location (proceedings-location - (raw-attr "booktitle") + (raw-attr* "booktitle") ;; optional: #:editor (parse-author (raw-attr "editor")) #:series (raw-attr "series") @@ -680,7 +680,7 @@ #:date (raw-attr "year") ;; TODO: optional month ;; optional: #:location (proceedings-location - (raw-attr "booktitle") + (raw-attr* "booktitle") ;; optional: #:editor (parse-author (raw-attr "editor")) #:volume (raw-attr "volume") ;; volume OR number