git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: Handle nested sdt tags.
7d3e7a5Jesse Rosenthal
src/Text/Pandoc/Readers/Docx/Parse.hs+1−1
@@ -136,7 +136,7 @@ unwrapSDT :: NameSpaces -> Content -> [Content]
136unwrapSDT ns (Elem element)
136unwrapSDT ns (Elem element)
137 | isElem ns "w" "sdt" element
137 | isElem ns "w" "sdt" element
138 , Just sdtContent <- findChildByName ns "w" "sdtContent" element
138 , Just sdtContent <- findChildByName ns "w" "sdtContent" element
139− = map Elem $ elChildren sdtContent
139+ = concatMap (unwrapSDT ns) $ map Elem $ elChildren sdtContent
140unwrapSDT _ content = [content]
140unwrapSDT _ content = [content]
141
141
142unwrapSDTchild :: NameSpaces -> Content -> Content
142unwrapSDTchild :: NameSpaces -> Content -> Content
test/Tests/Readers/Docx.hs+4
@@ -178,6 +178,10 @@ tests = [ testGroup "inlines"
178 "inlines inside of Structured Document Tags"
178 "inlines inside of Structured Document Tags"
179 "docx/sdt_elements.docx"
179 "docx/sdt_elements.docx"
180 "docx/sdt_elements.native"
180 "docx/sdt_elements.native"
181+ , testCompare
182+ "nested Structured Document Tags"
183+ "docx/nested_sdt.docx"
184+ "docx/nested_sdt.native"
181 , testCompare
185 , testCompare
182 "remove anchor spans with nothing pointing to them"
186 "remove anchor spans with nothing pointing to them"
183 "docx/unused_anchors.docx"
187 "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"]]