aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-08-16 15:39:56 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-08-16 15:39:56 -0700
commit7672997d18084bf2b12005eb73fd2453245637e4 (patch)
tree9e203415852cb247722b654bc4e2c2815c539b3f /src/Text/Pandoc/Readers/Docx.hs
parentb5782456506d585f4fbc7fd59556f29430c172b8 (diff)
parent9bb0b99981bb23eb0afe1befa78f34614fff3ecf (diff)
downloadpandoc-7672997d18084bf2b12005eb73fd2453245637e4.tar.gz
Merge pull request #1540 from jkr/charStyles
Char styles
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx.hs')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 823755a51..a1c16a03a 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -165,7 +165,7 @@ bodyPartsToMeta' (bp : bps)
| (Paragraph pPr parParts) <- bp
, (c : _)<- intersect (pStyle pPr) (M.keys metaStyles)
, (Just metaField) <- M.lookup c metaStyles = do
- inlines <- parPartsToInlines parParts
+ inlines <- concatReduce <$> mapM parPartToInlines parParts
remaining <- bodyPartsToMeta' bps
let
f (MetaInlines ils) (MetaInlines ils') = MetaBlocks [Para ils, Para ils']
@@ -218,11 +218,8 @@ runElemToString (TextRun s) = s
runElemToString (LnBrk) = ['\n']
runElemToString (Tab) = ['\t']
-runElemsToString :: [RunElem] -> String
-runElemsToString = concatMap runElemToString
-
runToString :: Run -> String
-runToString (Run _ runElems) = runElemsToString runElems
+runToString (Run _ runElems) = concatMap runElemToString runElems
runToString _ = ""
parPartToString :: ParPart -> String
@@ -242,14 +239,14 @@ runStyleToTransform rPr
, s `elem` emphStyles =
let rPr' = rPr{rStyle = Nothing, isItalic = Nothing}
in
- case isItalic rPr' of
+ case isItalic rPr of
Just False -> runStyleToTransform rPr'
_ -> emph . (runStyleToTransform rPr')
| Just s <- rStyle rPr
, s `elem` strongStyles =
let rPr' = rPr{rStyle = Nothing, isBold = Nothing}
in
- case isItalic rPr' of
+ case isBold rPr of
Just False -> runStyleToTransform rPr'
_ -> strong . (runStyleToTransform rPr')
| Just True <- isItalic rPr =
@@ -272,7 +269,7 @@ runToInlines :: Run -> DocxContext Inlines
runToInlines (Run rs runElems)
| Just s <- rStyle rs
, s `elem` codeStyles =
- return $ code $ runElemsToString runElems
+ return $ code $ concatMap runElemToString runElems
| otherwise = do
let ils = concatReduce (map runElemToInlines runElems)
return $ (runStyleToTransform rs) ils
@@ -383,9 +380,6 @@ makeHeaderAnchor' (Header n (_, classes, kvs) ils) =
return $ Header n (newIdent, classes, kvs) ils
makeHeaderAnchor' blk = return blk
-parPartsToInlines :: [ParPart] -> DocxContext Inlines
-parPartsToInlines parparts = concatReduce <$> mapM parPartToInlines parparts
-
cellToBlocks :: Cell -> DocxContext Blocks
cellToBlocks (Cell bps) = concatReduce <$> mapM bodyPartToBlocks bps
@@ -447,12 +441,12 @@ bodyPartToBlocks (Paragraph pPr parparts)
| (c : cs) <- filter (isJust . isHeaderClass) $ pStyle pPr
, Just n <- isHeaderClass c = do
ils <- local (\s-> s{docxInHeaderBlock=True}) $
- (parPartsToInlines parparts)
+ (concatReduce <$> mapM parPartToInlines parparts)
makeHeaderAnchor $
headerWith ("", delete ("Heading" ++ show n) cs, []) n ils
| otherwise = do
- ils <- parPartsToInlines parparts >>=
+ ils <- concatReduce <$> mapM parPartToInlines parparts >>=
(return . fromList . trimLineBreaks . normalizeSpaces . toList)
dropIls <- gets docxDropCap
let ils' = dropIls <> ils