From 8552e188cdac82ad6810a9b58450671fc4ceca18 Mon Sep 17 00:00:00 2001
From: Jesse Rosenthal <jrosenthal@jhu.edu>
Date: Tue, 12 Feb 2019 16:27:09 -0500
Subject: [PATCH] Docx reader: unwrap sdt elements in footnotes and comments.

We had previously walked the document to unwrap sdt/sdtContent and
smartTag tags in `word/document.xml`, but not in the
`word/{foot/end}note.xml` and `word/comments.xml`.

Closes #5302
---
 src/Text/Pandoc/Readers/Docx/Parse.hs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 16bd487f4..468bc0acc 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -486,8 +486,8 @@ archiveToNotes zf =
         Just e  -> elemToNameSpaces e
         Nothing -> []
       ns = unionBy (\x y -> fst x == fst y) fn_namespaces en_namespaces
-      fn = fnElem >>= elemToNotes ns "footnote"
-      en = enElem >>= elemToNotes ns "endnote"
+      fn = fnElem >>= walkDocument ns >>= elemToNotes ns "footnote"
+      en = enElem >>= walkDocument ns >>= elemToNotes ns "endnote"
   in
    Notes ns fn en
 
@@ -498,7 +498,7 @@ archiveToComments zf =
       cmts_namespaces = case cmtsElem of
         Just e  -> elemToNameSpaces e
         Nothing -> []
-      cmts = elemToComments cmts_namespaces <$> cmtsElem
+      cmts = elemToComments cmts_namespaces <$> (cmtsElem >>= walkDocument cmts_namespaces)
   in
     case cmts of
       Just c  -> Comments cmts_namespaces c