git.iko.soy/typeable/pandoc
on master help sign in
docbook reader: fix nesting of chapters and sections (#5864)
c6e936dFlorian Klink
pandoc.cabal+1
@@ -215,6 +215,7 @@ extra-source-files:
215 test/command/3510-export.latex
215 test/command/3510-export.latex
216 test/command/3510-src.hs
216 test/command/3510-src.hs
217 test/command/3971b.tex
217 test/command/3971b.tex
218+ test/docbook-chapter.docbook
218 test/docbook-reader.docbook
219 test/docbook-reader.docbook
219 test/docbook-xref.docbook
220 test/docbook-xref.docbook
220 test/html-reader.html
221 test/html-reader.html
src/Text/Pandoc/Readers/DocBook.hs+1−1
@@ -726,7 +726,7 @@ parseBlock (Elem e) =
726 mapM parseGlossEntry (filterChildren (named "glossentry") e)
726 mapM parseGlossEntry (filterChildren (named "glossentry") e)
727 "glosslist" -> definitionList <$>
727 "glosslist" -> definitionList <$>
728 mapM parseGlossEntry (filterChildren (named "glossentry") e)
728 mapM parseGlossEntry (filterChildren (named "glossentry") e)
729− "chapter" -> sect 0
729+ "chapter" -> modify (\st -> st{ dbBook = True}) >> sect 0
730 "appendix" -> sect 0
730 "appendix" -> sect 0
731 "preface" -> sect 0
731 "preface" -> sect 0
732 "bridgehead" -> para . strong <$> getInlines e
732 "bridgehead" -> para . strong <$> getInlines e
test/Tests/Old.hs+2
@@ -85,6 +85,8 @@ tests pandocPath =
85 [ testGroup "writer" $ writerTests' "docbook4"
85 [ testGroup "writer" $ writerTests' "docbook4"
86 , test' "reader" ["-r", "docbook", "-w", "native", "-s"]
86 , test' "reader" ["-r", "docbook", "-w", "native", "-s"]
87 "docbook-reader.docbook" "docbook-reader.native"
87 "docbook-reader.docbook" "docbook-reader.native"
88+ , test' "reader" ["-r", "docbook", "-w", "native", "-s"]
89+ "docbook-chapter.docbook" "docbook-chapter.native"
88 , test' "reader" ["-r", "docbook", "-w", "native", "-s"]
90 , test' "reader" ["-r", "docbook", "-w", "native", "-s"]
89 "docbook-xref.docbook" "docbook-xref.native"
91 "docbook-xref.docbook" "docbook-xref.native"
90 ]
92 ]
test/docbook-chapter.docbooknew file+30
@@ -0,0 +1,30 @@
1+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
2+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
3+<!-- This matches the example from
4+https://tdg.docbook.org/tdg/4.5/section.html, sans sectioninfo and subtitle, as
5+they're currently not supported -->
6+<chapter><title>Test Chapter</title>
7+<para>This chapter uses recursive sections.</para>
8+<section>
9+<title>Like a Sect1</title>
10+<para>This section is like a Sect1.</para>
11+<section><title>Like a Sect2</title>
12+<para>This section is like a Sect2.</para>
13+<section><title>Like a Sect3</title>
14+<para>This section is like a Sect3.</para>
15+<section><title>Like a Sect4</title>
16+<para>This section is like a Sect4.</para>
17+<section><title>Like a Sect5</title>
18+<para>This section is like a Sect5.</para>
19+<section><title>Would be like a Sect6</title>
20+<para>This section would be like a Sect6, if there was one.</para>
21+<section><title>Would be like a Sect7</title>
22+<para>This section would be like a Sect7, if there was one.</para>
23+</section>
24+</section>
25+</section>
26+</section>
27+</section>
28+</section>
29+</section>
30+</chapter>
test/docbook-chapter.nativenew file+17
@@ -0,0 +1,17 @@
1+Pandoc (Meta {unMeta = fromList []})
2+[Header 1 ("",[],[]) [Str "Test",Space,Str "Chapter"]
3+,Para [Str "This",Space,Str "chapter",Space,Str "uses",Space,Str "recursive",Space,Str "sections."]
4+,Header 2 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect1"]
5+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect1."]
6+,Header 3 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect2"]
7+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect2."]
8+,Header 4 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect3"]
9+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect3."]
10+,Header 5 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect4"]
11+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect4."]
12+,Header 6 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect5"]
13+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect5."]
14+,Header 7 ("",[],[]) [Str "Would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect6"]
15+,Para [Str "This",Space,Str "section",Space,Str "would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect6,",Space,Str "if",Space,Str "there",Space,Str "was",Space,Str "one."]
16+,Header 8 ("",[],[]) [Str "Would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect7"]
17+,Para [Str "This",Space,Str "section",Space,Str "would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect7,",Space,Str "if",Space,Str "there",Space,Str "was",Space,Str "one."]]