Skip to content

Commit 1090d1e

Browse files
authored
multiple-bibliographies: respect cs:bibliography attrib configs (#160)
* Update test * Set the same classes and attributes to the custom references divs as citeproc did for the temporary div
1 parent 1e71509 commit 1090d1e

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

multiple-bibliographies/expected.native

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Pandoc (Meta {unMeta = fromList [("bibliography_recommended_reading",MetaInlines [Str "secondary.bib"]),("bibliography_sources",MetaInlines [Str "primary.bib"]),("nocite",MetaInlines [Cite [Citation {citationId = "Knu86", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 1, citationHash = 0}] [Str "@Knu86"],Str ",",Space,Cite [Citation {citationId = "Bae", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 2, citationHash = 0}] [Str "@Bae"]]),("title",MetaInlines [Str "Multiple",Space,Str "Bibliographies",Space,Str "Demo"])]})
22
[Para [Cite [Citation {citationId = "Nie72", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 3, citationHash = 0}] [Str "Nietzsche",Space,Str "(1872)"],Str ",",Space,Cite [Citation {citationId = "Bel", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 4, citationHash = 0}] [Str "Bellori",Space,Str "(1672)"]]
33
,Header 1 ("references",[],[]) [Str "References"]
4-
,Div ("refs_sources",["csl-bib-body"],[])
4+
,Div ("refs_sources",["references","csl-bib-body","hanging-indent"],[])
55
[Div ("ref-Bel",["csl-entry"],[])
66
[Para [Str "Bellori.",Space,Str "1672.",Space,Emph [Str "Le",Space,Str "Vite",Space,Str "de\8217",Space,Str "Pittori,",Space,Str "Scultori",Space,Str "e",Space,Str "Architetti",Space,Str "Moderni"],Str "."]]
77
,Div ("ref-Nie72",["csl-entry"],[])
88
[Para [Str "Nietzsche,",Space,Str "Friedrich.",Space,Str "1872.",Space,Emph [Str "Die",Space,Str "Geburt",Space,Str "Der",Space,Str "Trag\246die",Space,Str "Aus",Space,Str "Dem",Space,Str "Geiste",Space,Str "Der",Space,Str "Musik"],Str "."]]]
99
,Header 1 ("recommended-reading",[],[]) [Str "Recommended",Space,Str "Reading"]
10-
,Div ("refs_recommended_reading",["csl-bib-body"],[])
10+
,Div ("refs_recommended_reading",["references","csl-bib-body","hanging-indent"],[])
1111
[Div ("ref-Bae",["csl-entry"],[])
1212
[Para [Str "B\228tschmann,",Space,Str "Oskar.",Space,Str "1985.",Space,Emph [Str "Pygmalion",Space,Str "Als",Space,Str "Betrachter"],Str "."]]
1313
,Div ("ref-Knu86",["csl-entry"],[])

multiple-bibliographies/multiple-bibliographies.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ local doc_meta = pandoc.Meta{}
2828
--- Div used by pandoc-citeproc to insert the bibliography.
2929
local refs_div = pandoc.Div({}, pandoc.Attr('refs'))
3030

31+
-- Div filled by pandoc-citeproc with properties set according to
32+
-- the output format and the attributes of cs:bibliography
33+
local refs_div_with_properties
34+
3135
local supports_quiet_flag = (function ()
3236
-- We use pandoc instead of pandoc-citeproc starting with pandoc 2.11
3337
if PANDOC_VERSION >= "2.11" then
@@ -76,8 +80,8 @@ local function resolve_doc_citations (doc)
7680
-- resolve all citations
7781
-- doc = run_json_filter(doc, 'pandoc-citeproc')
7882
doc = run_citeproc(doc)
79-
-- remove catch-all bibliography
80-
table.remove(doc.blocks)
83+
-- remove catch-all bibliography and keep it for future use
84+
refs_div_with_properties = table.remove(doc.blocks)
8185
-- restore bibliography to original value
8286
doc.meta.bibliography = orig_bib
8387
return doc
@@ -118,11 +122,9 @@ local function create_topic_bibliography (div)
118122
-- First block of the result contains the dummy paragraph, second is
119123
-- the refs Div filled by pandoc-citeproc.
120124
div.content = res.blocks[2].content
121-
-- ensure that the div has class 'csl-bib-body'. The LaTeX writer expects it
122-
-- as a marker for reference divs.
123-
div.classes = div.classes:includes 'csl-bib-body'
124-
and div.classes
125-
or div.classes .. {'csl-bib-body'}
125+
-- Set the classes and attributes as pandoc-citeproc did it on refs_div
126+
div.classes = refs_div_with_properties.classes
127+
div.attributes = refs_div_with_properties.attributes
126128
return div
127129
end
128130

0 commit comments

Comments
 (0)