git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: optimized nonindentSpaces.
be73338John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+3−6
@@ -133,17 +133,14 @@ indentSpaces = try $ do
133
133
134nonindentSpaces :: PandocMonad m => MarkdownParser m String
134nonindentSpaces :: PandocMonad m => MarkdownParser m String
135nonindentSpaces = do
135nonindentSpaces = do
136− tabStop <- getOption readerTabStop
136+ n <- skipNonindentSpaces
137− sps <- many (char ' ')
138− if length sps < tabStop
139− then return sps
137+ return $ replicate n ' '
140− else unexpected "indented line"
141
138
142-- returns number of spaces parsed
139-- returns number of spaces parsed
143skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
140skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
144skipNonindentSpaces = do
141skipNonindentSpaces = do
145 tabStop <- getOption readerTabStop
142 tabStop <- getOption readerTabStop
146− atMostSpaces (tabStop - 1) <* notFollowedBy (char ' ')
143+ atMostSpaces (tabStop - 1) <* notFollowedBy spaceChar
147
144
148atMostSpaces :: PandocMonad m => Int -> MarkdownParser m Int
145atMostSpaces :: PandocMonad m => Int -> MarkdownParser m Int
149atMostSpaces n
146atMostSpaces n