diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2018-02-28 16:27:18 -0500 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2018-02-28 16:32:20 -0500 |
commit | 7d3e7a5a6d9e7b139fd15e10a52b85f87aba42b1 (patch) | |
tree | 3c9ea9021a3dd72867820cf21653d73bcc031544 | |
parent | cc3477192809030044dc0729c42fcf4cf96bb5a9 (diff) | |
download | pandoc-7d3e7a5a6d9e7b139fd15e10a52b85f87aba42b1.tar.gz |
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
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 2 | ||||
-rw-r--r-- | test/Tests/Readers/Docx.hs | 4 | ||||
-rw-r--r-- | test/docx/nested_sdt.docx | bin | 0 -> 11694 bytes | |||
-rw-r--r-- | test/docx/nested_sdt.native | 3 |
4 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index c123a0018..1f7f07e36 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -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 diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index cef80d6d1..0ba765c93 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -179,6 +179,10 @@ tests = [ testGroup "inlines" "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" "docx/unused_anchors.native" diff --git a/test/docx/nested_sdt.docx b/test/docx/nested_sdt.docx Binary files differnew file mode 100644 index 000000000..1a0827db3 --- /dev/null +++ b/test/docx/nested_sdt.docx diff --git a/test/docx/nested_sdt.native b/test/docx/nested_sdt.native new file mode 100644 index 000000000..d0adc05ac --- /dev/null +++ b/test/docx/nested_sdt.native @@ -0,0 +1,3 @@ +[Para [Str "Test",Space,Str "Paragraph1"] +,Para [Str "Test",Space,Str "Paragraph2"] +,Para [Str "Test",Space,Str "Paragraph3"]] |