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:
parent
cc34771928
commit
7d3e7a5a6d
4 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
BIN
test/docx/nested_sdt.docx
Normal file
Binary file not shown.
3
test/docx/nested_sdt.native
Normal file
3
test/docx/nested_sdt.native
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Para [Str "Test",Space,Str "Paragraph1"]
|
||||
,Para [Str "Test",Space,Str "Paragraph2"]
|
||||
,Para [Str "Test",Space,Str "Paragraph3"]]
|
Loading…
Add table
Reference in a new issue