diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-05 18:27:05 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-10-05 18:27:05 +0300 |
commit | 7cfce586f6ef6e97934c48f8871741aa0e8379dc (patch) | |
tree | c3f1cc5b8954c6e87df3bc32a4aa52d45d597661 /src/Text/Pandoc/Readers | |
parent | abd770c691ce09ff74e175f5bd25de2058d3c766 (diff) | |
download | pandoc-7cfce586f6ef6e97934c48f8871741aa0e8379dc.tar.gz |
Muse reader: reduce duplication by introducing `getIndent`
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index aaa9d2eb1..39d835af7 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -548,6 +548,10 @@ lineBlock = try $ do -- *** List parsers +getIndent :: PandocMonad m + => MuseParser m Int +getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition + bulletListItemsUntil :: PandocMonad m => Int -- ^ Indentation -> MuseParser m a -- ^ Terminator parser @@ -564,9 +568,7 @@ bulletListUntil :: PandocMonad m => MuseParser m a -> MuseParser m (F Blocks, a) bulletListUntil end = try $ do - many spaceChar - pos <- getPosition - let indent = sourceColumn pos - 1 + indent <- getIndent guard $ indent /= 0 (items, e) <- bulletListItemsUntil indent end return (B.bulletList <$> sequence items, e) @@ -604,9 +606,7 @@ orderedListUntil :: PandocMonad m => MuseParser m a -> MuseParser m (F Blocks, a) orderedListUntil end = try $ do - many spaceChar - pos <- getPosition - let indent = sourceColumn pos - 1 + indent <- getIndent guard $ indent /= 0 (style, start) <- decimal <|> lowerRoman <|> upperRoman <|> lowerAlpha <|> upperAlpha char '.' @@ -642,9 +642,7 @@ definitionListUntil :: PandocMonad m => MuseParser m a -- ^ Terminator parser -> MuseParser m (F Blocks, a) definitionListUntil end = try $ do - many spaceChar - pos <- getPosition - let indent = sourceColumn pos - 1 + indent <- getIndent guardDisabled Ext_amuse <|> guard (indent /= 0) -- Initial space is required by Amusewiki, but not Emacs Muse first (fmap B.definitionList . sequence) <$> definitionListItemsUntil indent end |