@@ -37,6 +37,7 @@ A utility library with parsers used in pandoc readers.
38module Text.Pandoc.Parsing ( anyLine,
38module Text.Pandoc.Parsing ( anyLine,
39 anyLineNewline,
39 anyLineNewline,
40 many1Till,
41 many1Till,
41 notFollowedBy',
42 notFollowedBy',
42 oneOfStrings,
43 oneOfStrings,
@@ -260,6 +261,17 @@ anyLine = do
260anyLineNewline :: Stream [Char] m Char => ParserT [Char] st m [Char]
261anyLineNewline :: Stream [Char] m Char => ParserT [Char] st m [Char]
261anyLineNewline = (++ "\n") <$> anyLine
262anyLineNewline = (++ "\n") <$> anyLine
264+-- | Parse indent by specified number of spaces (or equiv. tabs)
265+indentWith :: Stream [Char] m Char
266+ => HasReaderOptions st
267+ => Int -> ParserT [Char] st m [Char]
269+ tabStop <- getOption readerTabStop
271+ then count num (char ' ')
272+ else choice [ try (count num (char ' '))
273+ , try (char '\t' >> indentWith (num - tabStop)) ]
263-- | Like @manyTill@, but reads at least one item.
275-- | Like @manyTill@, but reads at least one item.
264many1Till :: Stream s m t
276many1Till :: Stream s m t
265 => ParserT s st m a
277 => ParserT s st m a