git.iko.soy/typeable/pandoc
on master help sign in
DocBook Reader: fix duplicate bibliography bug (#6773)

Also add unit test to ensure the behavior stays consistent.

commitdd3d920ba096b3415e11ea0a26d1f5efa4b18cc9 authorNils Carlson <nils@nilscarlson.se> dateMon 26 Oct 2020, 19:49 (6 years ago) parent9ab04a9
2 files changed+24−5
src/Text/Pandoc/Readers/DocBook.hs+4−5 test/command/docbook-bibliography.md+20
src/Text/Pandoc/Readers/DocBook.hs+4−5
@@ -794,11 +794,10 @@ parseBlock (Elem e) =
794794 "titleabbrev" -> skip
795795 "authorinitials" -> skip
796796 "bibliography" -> sect 0
797− "bibliodiv" -> do
798− tit <- case filterChild (named "title") e of
799− Just _ -> sect 1
800− Nothing -> return mempty
801− (tit <>) <$> parseMixed para (elContent e)
797+ "bibliodiv" ->
798+ case filterChild (named "title") e of
799+ Just _ -> sect 1
800+ Nothing -> return mempty
802801 "biblioentry" -> parseMixed para (elContent e)
803802 "bibliomisc" -> parseMixed para (elContent e)
804803 "bibliomixed" -> parseMixed para (elContent e)
test/command/docbook-bibliography.mdnew file+20
@@ -0,0 +1,20 @@
1+```
2+% pandoc -f docbook -t native --quiet
3+<bibliodiv>
4+<title>Document References</title>
5+<bibliomixed>
6+<bibliomisc><anchor xml:id="refTheFirst" xreflabel="[1]"/>[1] First reference</bibliomisc>
7+</bibliomixed>
8+<bibliomixed>
9+<bibliomisc><anchor xml:id="refTheSecond" xreflabel="[2]"/>[2] Second reference</bibliomisc>
10+</bibliomixed>
11+<bibliomixed>
12+<bibliomisc><anchor xml:id="refTheThird" xreflabel="[3]"/>[3] Third reference</bibliomisc>
13+</bibliomixed>
14+</bibliodiv>
15+^D
16+[Header 1 ("",[],[]) [Str "Document",Space,Str "References"]
17+,Para [Span ("refTheFirst",[],[]) [],Str "[1]",Space,Str "First",Space,Str "reference"]
18+,Para [Span ("refTheSecond",[],[]) [],Str "[2]",Space,Str "Second",Space,Str "reference"]
19+,Para [Span ("refTheThird",[],[]) [],Str "[3]",Space,Str "Third",Space,Str "reference"]]
20+```