diff --git a/src/Text/Pandoc/Readers/LaTeX/Inline.hs b/src/Text/Pandoc/Readers/LaTeX/Inline.hs index 7b8bca4af..8e6beca68 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Inline.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Inline.hs @@ -163,12 +163,12 @@ accentWith :: PandocMonad m accentWith tok combiningAccent fallBack = try $ do ils <- tok case toList ils of + [Str " "] -> return $ str $ T.singleton + $ fromMaybe combiningAccent fallBack (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $ -- try to normalize to the combined character: Str (Normalize.normalize Normalize.NFC (T.pack [x, combiningAccent]) <> xs) : ys - [Space] -> return $ str $ T.singleton - $ fromMaybe combiningAccent fallBack [] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack _ -> return ils diff --git a/src/Text/Pandoc/Readers/LaTeX/Math.hs b/src/Text/Pandoc/Readers/LaTeX/Math.hs index 5b49a0376..2143e0f19 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Math.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Math.hs @@ -200,7 +200,7 @@ addTitle :: Inlines -> Blocks -> Blocks addTitle ils bs = case B.toList bs of (Para xs : rest) - -> B.fromList (Para (B.toList ils ++ (Space : xs)) : rest) + -> B.fromList (Para (B.toList ils ++ (Str " " : xs)) : rest) _ -> B.para ils <> bs addQed :: Blocks -> Blocks diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 1141af66f..780ef60fe 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -393,7 +393,6 @@ parseCodeBlock = try $ do getText :: Inline -> T.Text getText (Str s) = s - getText Space = " " getText (Code _ s) = s getText SoftBreak = "\n" getText LineBreak = "\n" diff --git a/src/Text/Pandoc/Readers/TikiWiki.hs b/src/Text/Pandoc/Readers/TikiWiki.hs index 5c414fdec..d94e083b3 100644 --- a/src/Text/Pandoc/Readers/TikiWiki.hs +++ b/src/Text/Pandoc/Readers/TikiWiki.hs @@ -18,7 +18,6 @@ module Text.Pandoc.Readers.TikiWiki ( readTikiWiki import Control.Monad import Control.Monad.Except (throwError) -import qualified Data.Foldable as F import Data.List (dropWhileEnd) import Data.Maybe (fromMaybe) import Data.Text (Text) @@ -176,9 +175,9 @@ para = fmap (result . mconcat) ( many1Till inline endOfParaElement) endOfInput = try $ skipMany blankline >> skipSpaces >> eof endOfPara = try $ blankline >> skipMany1 blankline newBlockElement = try $ blankline >> skip blockElements - result content = if F.all (==Space) content - then mempty - else B.para $ B.trimInlines content + result content = case B.trimInlines content of + ils | null ils -> mempty + | otherwise -> B.para ils -- ;item 1: definition 1 -- ;item 2: definition 2-1 diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 0b7c6bee0..6db06408f 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -182,7 +182,7 @@ isDisplayMath (Math DisplayMath _) = True isDisplayMath (Span _ [Math DisplayMath _]) = True isDisplayMath _ = False --- | Remove leading and trailing 'Space' and 'SoftBreak' elements. +-- | Remove leading and trailing spaces and 'SoftBreak' elements. stripLeadingTrailingSpace :: [Inline] -> [Inline] stripLeadingTrailingSpace = go . reverse . go . reverse where go (Space:xs) = xs @@ -440,7 +440,7 @@ sectionToListItem opts (Div (ident,_,_) addNumber = if T.null num then id else (Span ("",["toc-section-number"],[]) - [Str num] :) . (Space :) + [Str num] :) . (Str " " :) headerText' = addNumber $ walk (deLink . deNote) ils headerLink = if T.null ident then headerText'