git.iko.soy/typeable/pandoc
on master help sign in
Move indentWith to Text.Pandoc.Parsing (#3687)
30a3deaAlexander Krotov
src/Text/Pandoc/Parsing.hs+12
@@ -37,6 +37,7 @@ A utility library with parsers used in pandoc readers.
37-}
37-}
38module Text.Pandoc.Parsing ( anyLine,
38module Text.Pandoc.Parsing ( anyLine,
39 anyLineNewline,
39 anyLineNewline,
40+ indentWith,
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
262
263
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]
268+indentWith num = do
269+ tabStop <- getOption readerTabStop
270+ if (num < tabStop)
271+ then count num (char ' ')
272+ else choice [ try (count num (char ' '))
273+ , try (char '\t' >> indentWith (num - tabStop)) ]
274+
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
src/Text/Pandoc/Readers/Org/Blocks.hs−9
@@ -828,12 +828,3 @@ listContinuation markerLength = try $
828 <*> many blankline)
828 <*> many blankline)
829 where
829 where
830 listLine = try $ indentWith markerLength *> anyLineNewline
830 listLine = try $ indentWith markerLength *> anyLineNewline
831−
832− -- indent by specified number of spaces (or equiv. tabs)
833− indentWith :: Monad m => Int -> OrgParser m String
834− indentWith num = do
835− tabStop <- getOption readerTabStop
836− if num < tabStop
837− then count num (char ' ')
838− else choice [ try (count num (char ' '))
839− , try (char '\t' >> count (num - tabStop) (char ' ')) ]
src/Text/Pandoc/Readers/Org/Parsing.hs+1
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Org.Parsing
32 ( OrgParser
32 ( OrgParser
33 , anyLine
33 , anyLine
34 , anyLineNewline
34 , anyLineNewline
35+ , indentWith
35 , blanklines
36 , blanklines
36 , newline
37 , newline
37 , parseFromString
38 , parseFromString
src/Text/Pandoc/Readers/RST.hs−9
@@ -561,15 +561,6 @@ listLine markerLength = try $ do
561 indentWith markerLength
561 indentWith markerLength
562 anyLineNewline
562 anyLineNewline
563
563
564−-- indent by specified number of spaces (or equiv. tabs)
565−indentWith :: Monad m => Int -> RSTParser m [Char]
566−indentWith num = do
567− tabStop <- getOption readerTabStop
568− if (num < tabStop)
569− then count num (char ' ')
570− else choice [ try (count num (char ' ')),
571− (try (char '\t' >> count (num - tabStop) (char ' '))) ]
572−
573-- parse raw text for one list item, excluding start marker and continuations
564-- parse raw text for one list item, excluding start marker and continuations
574rawListItem :: Monad m => RSTParser m Int
565rawListItem :: Monad m => RSTParser m Int
575 -> RSTParser m (Int, [Char])
566 -> RSTParser m (Int, [Char])
src/Text/Pandoc/Readers/Txt2Tags.hs−3
@@ -277,9 +277,6 @@ listContinuation markerLength = try $
277 <*> many blankline)
277 <*> many blankline)
278 where listLine = try $ indentWith markerLength *> anyLineNewline
278 where listLine = try $ indentWith markerLength *> anyLineNewline
279
279
280−indentWith :: Int -> T2T String
281−indentWith n = count n spaceChar
282−
283-- Table
280-- Table
284
281
285table :: T2T Blocks
282table :: T2T Blocks