diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/TikiWiki.hs | 9 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 10 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 12 |
3 files changed, 18 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/TikiWiki.hs b/src/Text/Pandoc/Readers/TikiWiki.hs index 8458b05e5..8e01a80f8 100644 --- a/src/Text/Pandoc/Readers/TikiWiki.hs +++ b/src/Text/Pandoc/Readers/TikiWiki.hs @@ -32,7 +32,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Logging (Verbosity (..)) import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (enclosed, nested) -import Text.Pandoc.Shared (crFilter) +import Text.Pandoc.Shared (crFilter, safeRead) import Text.Pandoc.XML (fromEntities) import Text.Printf (printf) @@ -500,9 +500,12 @@ emph = try $ fmap B.emph (enclosed (string "''") nestedInlines) escapedChar :: PandocMonad m => TikiWikiParser m B.Inlines escapedChar = try $ do string "~" - inner <- many1 $ oneOf "0123456789" + mNumber <- safeRead <$> many1 digit string "~" - return $B.str [toEnum (read inner :: Int) :: Char] + return $ B.str $ + case mNumber of + Just number -> [toEnum (number :: Int) :: Char] + Nothing -> [] -- UNSUPPORTED, as there doesn't seem to be any facility in calibre -- for this diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index c2a160320..4f642871a 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -234,11 +234,11 @@ writeDocx opts doc@(Pandoc meta _) = do -- Get the available area (converting the size and the margins to int and -- doing the difference - let pgContentWidth = (-) <$> (read <$> mbAttrSzWidth ::Maybe Integer) - <*> ( - (+) <$> (read <$> mbAttrMarRight ::Maybe Integer) - <*> (read <$> mbAttrMarLeft ::Maybe Integer) - ) + let pgContentWidth = mbAttrSzWidth >>= safeRead + >>= subtrct mbAttrMarRight + >>= subtrct mbAttrMarLeft + where + subtrct mbStr = \x -> mbStr >>= safeRead >>= (\y -> Just $ x - y) -- styles mblang <- toLang $ getLang opts meta diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ca8295f0a..f9bee886e 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -553,16 +553,18 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) else id wrapColumn = if "column" `elem` classes then \contents -> - let fromPct xs = - case reverse xs of - '%':ds -> showFl (read (reverse ds) / 100 :: Double) - _ -> xs - w = maybe "0.48" fromPct (lookup "width" kvs) + let w = maybe "0.48" fromPct (lookup "width" kvs) in inCmd "begin" "column" <> braces (text w <> "\\textwidth") $$ contents $$ inCmd "end" "column" else id + fromPct xs = + case reverse xs of + '%':ds -> case safeRead (reverse ds) of + Just digits -> showFl (digits / 100 :: Double) + Nothing -> xs + _ -> xs wrapDir = case lookup "dir" kvs of Just "rtl" -> align "RTL" Just "ltr" -> align "LTR" |