git.iko.soy/typeable/pandoc
on master help sign in
Move indentWith to Text.Pandoc.Parsing (#3687)
commit30a3deadcce18dd53a79a4915d915beb815702cf authorAlexander Krotov <ilabdsf@gmail.com> dateMon 22 May 2017, 11:10 (9 years ago) parentaa1e398
5 files changed+13−21
src/Text/Pandoc/Parsing.hs+12 src/Text/Pandoc/Readers/Org/Blocks.hs−9 src/Text/Pandoc/Readers/Org/Parsing.hs+1 src/Text/Pandoc/Readers/RST.hs−9 src/Text/Pandoc/Readers/Txt2Tags.hs−3
src/Text/Pandoc/Parsing.hs+12
@@ -37,6 +37,7 @@ A utility library with parsers used in pandoc readers.
3737-}
3838module Text.Pandoc.Parsing ( anyLine,
3939 anyLineNewline,
40+ indentWith,
4041 many1Till,
4142 notFollowedBy',
4243 oneOfStrings,
@@ -260,6 +261,17 @@ anyLine = do
260261anyLineNewline :: Stream [Char] m Char => ParserT [Char] st m [Char]
261262anyLineNewline = (++ "\n") <$> anyLine
262263
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+
263275-- | Like @manyTill@, but reads at least one item.
264276many1Till :: Stream s m t
265277 => ParserT s st m a
src/Text/Pandoc/Readers/Org/Blocks.hs−9
@@ -828,12 +828,3 @@ listContinuation markerLength = try $
828828 <*> many blankline)
829829 where
830830 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
3232 ( OrgParser
3333 , anyLine
3434 , anyLineNewline
35+ , indentWith
3536 , blanklines
3637 , newline
3738 , parseFromString
src/Text/Pandoc/Readers/RST.hs−9
@@ -561,15 +561,6 @@ listLine markerLength = try $ do
561561 indentWith markerLength
562562 anyLineNewline
563563
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−
573564-- parse raw text for one list item, excluding start marker and continuations
574565rawListItem :: Monad m => RSTParser m Int
575566 -> RSTParser m (Int, [Char])
src/Text/Pandoc/Readers/Txt2Tags.hs−3
@@ -277,9 +277,6 @@ listContinuation markerLength = try $
277277 <*> many blankline)
278278 where listLine = try $ indentWith markerLength *> anyLineNewline
279279
280−indentWith :: Int -> T2T String
281−indentWith n = count n spaceChar
282−
283280-- Table
284281
285282table :: T2T Blocks