Docx reader: Handle nested sdt tags.
Previously we had only unwrapped one level of sdt tags. Now we recurse
if we find them.
Closes: #4415
commit7d3e7a5a6d9e7b139fd15e10a52b85f87aba42b1
authorJesse Rosenthal <jrosenthal@jhu.edu>
dateWed 28 Feb 2018, 16:27 (9 years ago)
parentcc34771
src/Text/Pandoc/Readers/Docx/Parse.hs+1−1
@@ -136,7 +136,7 @@ unwrapSDT :: NameSpaces -> Content -> [Content]
136136unwrapSDT ns (Elem element)
137137 | isElem ns "w" "sdt" element
138138 , Just sdtContent <- findChildByName ns "w" "sdtContent" element
139− = map Elem $ elChildren sdtContent
139+ = concatMap (unwrapSDT ns) $ map Elem $ elChildren sdtContent
140140unwrapSDT _ content = [content]
141141
142142unwrapSDTchild :: NameSpaces -> Content -> Content
test/Tests/Readers/Docx.hs+4
@@ -178,6 +178,10 @@ tests = [ testGroup "inlines"
178178 "inlines inside of Structured Document Tags"
179179 "docx/sdt_elements.docx"
180180 "docx/sdt_elements.native"
181+ , testCompare
182+ "nested Structured Document Tags"
183+ "docx/nested_sdt.docx"
184+ "docx/nested_sdt.native"
181185 , testCompare
182186 "remove anchor spans with nothing pointing to them"
183187 "docx/unused_anchors.docx"
test/docx/nested_sdt.docxnew file
Binary file not shown.
test/docx/nested_sdt.nativenew file+3
@@ -0,0 +1,3 @@
1+[Para [Str "Test",Space,Str "Paragraph1"]
2+,Para [Str "Test",Space,Str "Paragraph2"]
3+,Para [Str "Test",Space,Str "Paragraph3"]]