aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-08-17 10:19:48 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-08-17 10:19:48 -0400
commitc4871ac79050c22387e2ef67cd8dcb69745567df (patch)
tree3a52063ebe484126391ec341d8441eba60ba3342 /src/Text/Pandoc/Readers
parent75eec0a6b8a4a65ae957fb416c0cdd2704b7739b (diff)
downloadpandoc-c4871ac79050c22387e2ef67cd8dcb69745567df.tar.gz
Docx Style parser: Basic one now just takes a parent style.
This will make it easier to build the style map from the bottom up (to avoid any infinite references).
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 43c2459d1..b431f70bf 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -279,7 +279,7 @@ elemToCharStyle ns element
, Just "character" <- findAttr (elemName ns "w" "type") element
, Just styleId <- findAttr (elemName ns "w" "styleId") element
, isJust $ findChild (elemName ns "w" "rPr") element =
- Just (styleId, elemToRunStyle ns element M.empty)
+ Just (styleId, elemToRunStyle ns element Nothing)
| otherwise = Nothing
@@ -695,12 +695,20 @@ checkOnOff ns rPr tag
checkOnOff _ _ _ = Nothing
elemToRunStyleD :: NameSpaces -> Element -> D RunStyle
-elemToRunStyleD ns element = do
- charStyles <- asks envCharStyles
- return $ elemToRunStyle ns element charStyles
+elemToRunStyleD ns element
+ | Just rPr <- findChild (elemName ns "w" "rPr") element = do
+ charStyles <- asks envCharStyles
+ let parentSty = case
+ findChild (elemName ns "w" "rStyle") rPr >>=
+ findAttr (elemName ns "w" "val")
+ of
+ Just styName -> Just $ (styName, M.lookup styName charStyles)
+ _ -> Nothing
+ return $ elemToRunStyle ns element parentSty
+elemToRunStyleD _ _ = return defaultRunStyle
-elemToRunStyle :: NameSpaces -> Element -> CharStyles -> RunStyle
-elemToRunStyle ns element charStyles
+elemToRunStyle :: NameSpaces -> Element -> Maybe (String, Maybe RunStyle) -> RunStyle
+elemToRunStyle ns element parentStyle
| Just rPr <- findChild (elemName ns "w" "rPr") element =
RunStyle
{
@@ -718,13 +726,7 @@ elemToRunStyle ns element charStyles
, rUnderline =
findChild (elemName ns "w" "u") rPr >>=
findAttr (elemName ns "w" "val")
- , rStyle =
- case
- findChild (elemName ns "w" "rStyle") rPr >>=
- findAttr (elemName ns "w" "val")
- of
- Just styName -> Just $ (styName, M.lookup styName charStyles)
- _ -> Nothing
+ , rStyle = parentStyle
}
elemToRunStyle _ _ _ = defaultRunStyle