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
This commit is contained in:
Jesse Rosenthal 2018-02-28 16:27:18 -05:00
parent cc34771928
commit 7d3e7a5a6d
4 changed files with 8 additions and 1 deletions

View file

@ -136,7 +136,7 @@ unwrapSDT :: NameSpaces -> Content -> [Content]
unwrapSDT ns (Elem element)
| isElem ns "w" "sdt" element
, Just sdtContent <- findChildByName ns "w" "sdtContent" element
= map Elem $ elChildren sdtContent
= concatMap (unwrapSDT ns) $ map Elem $ elChildren sdtContent
unwrapSDT _ content = [content]
unwrapSDTchild :: NameSpaces -> Content -> Content

View file

@ -178,6 +178,10 @@ tests = [ testGroup "inlines"
"inlines inside of Structured Document Tags"
"docx/sdt_elements.docx"
"docx/sdt_elements.native"
, testCompare
"nested Structured Document Tags"
"docx/nested_sdt.docx"
"docx/nested_sdt.native"
, testCompare
"remove anchor spans with nothing pointing to them"
"docx/unused_anchors.docx"

BIN
test/docx/nested_sdt.docx Normal file

Binary file not shown.

View file

@ -0,0 +1,3 @@
[Para [Str "Test",Space,Str "Paragraph1"]
,Para [Str "Test",Space,Str "Paragraph2"]
,Para [Str "Test",Space,Str "Paragraph3"]]