@@ -256,15 +256,15 @@ imageBlock = try $ do
256256imageDef :: Inlines -> RSTParser Inlines
257257imageDef defaultAlt = try $ do
258258 string "image:: "
259− src <- escapeURI . removeLeadingTrailingSpace <$> manyTill anyChar newline
259+ src <- escapeURI . trim <$> manyTill anyChar newline
260260 fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
261261 many $ rawFieldListItem indent
262262 optional blanklines
263− let alt = maybe defaultAlt (\x -> B.str $ removeTrailingSpace x)
263+ let alt = maybe defaultAlt (\x -> B.str $ trimr x)
264264 $ lookup "alt" fields
265265 let img = B.image src "" alt
266266 return $ case lookup "target" fields of
267− Just t -> B.link (escapeURI $ removeLeadingTrailingSpace t)
267+ Just t -> B.link (escapeURI $ trim t)
268268 "" img
269269 Nothing -> img
270270
@@ -381,7 +381,7 @@ customCodeBlock = try $ do
381381figureBlock :: RSTParser Blocks
382382figureBlock = try $ do
383383 string ".. figure::"
384− src <- escapeURI . removeLeadingTrailingSpace <$> manyTill anyChar newline
384+ src <- escapeURI . trim <$> manyTill anyChar newline
385385 body <- indentedBlock
386386 caption <- parseFromString extractCaption body
387387 return $ B.para $ B.image src "" caption
@@ -540,7 +540,7 @@ defaultRoleBlock :: RSTParser Blocks
540540defaultRoleBlock = try $ do
541541 string ".. default-role::"
542542 -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one
543− role <- manyTill anyChar newline >>= return . removeLeadingTrailingSpace
543+ role <- manyTill anyChar newline >>= return . trim
544544 updateState $ \s -> s { stateRstDefaultRole =
545545 if null role
546546 then stateRstDefaultRole defaultParserState
@@ -587,7 +587,7 @@ directive = try $ do
587587-- divide string by blanklines
588588toChunks :: String -> [String]
589589toChunks = dropWhile null
590− . map (removeLeadingTrailingSpace . unlines)
590+ . map (trim . unlines)
591591 . splitBy (all (`elem` " \t")) . lines
592592
593593---
@@ -674,7 +674,7 @@ targetURI = do
674674 contents <- many1 (try (many spaceChar >> newline >>
675675 many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")
676676 blanklines
677− return $ escapeURI $ removeLeadingTrailingSpace $ contents
677+ return $ escapeURI $ trim $ contents
678678
679679imageKey :: RSTParser ()
680680imageKey = try $ do
@@ -758,7 +758,7 @@ simpleTableRow indices = do
758758
759759simpleTableSplitLine :: [Int] -> String -> [String]
760760simpleTableSplitLine indices line =
761− map removeLeadingTrailingSpace
761+ map trim
762762 $ tail $ splitByIndices (init indices) line
763763
764764simpleTableHeader :: Bool -- ^ Headerless table
@@ -777,7 +777,7 @@ simpleTableHeader headless = try $ do
777777 then replicate (length dashes) ""
778778 else simpleTableSplitLine indices rawContent
779779 heads <- mapM (parseFromString (B.toList . mconcat <$> many plain)) $
780− map removeLeadingTrailingSpace rawHeads
780+ map trim rawHeads
781781 return (heads, aligns, indices)
782782
783783-- Parse a simple table.
@@ -845,7 +845,7 @@ code = try $ do
845845 string "``"
846846 result <- manyTill anyChar (try (string "``"))
847847 return $ B.code
848− $ removeLeadingTrailingSpace $ unwords $ lines result
848+ $ trim $ unwords $ lines result
849849
850850-- succeeds only if we're not right after a str (ie. in middle of word)
851851atStart :: RSTParser a -> RSTParser a
@@ -932,7 +932,7 @@ explicitLink = try $ do
932932 src <- manyTill (noneOf ">\n") (char '>')
933933 skipSpaces
934934 string "`_"
935− return $ B.link (escapeURI $ removeLeadingTrailingSpace src) "" label'
935+ return $ B.link (escapeURI $ trim src) "" label'
936936
937937referenceLink :: RSTParser Inlines
938938referenceLink = try $ do