aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-10-16 19:25:45 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-10-16 19:26:54 +0300
commit7f814c533988362b341ec64cf2b12a42d745975d (patch)
treee9cef8f8e08e46e7d5a738ee41ff50d709af29b6
parenta5fc46cb8f3903dc4f2f42ed8bc2cd06c2fa2872 (diff)
downloadpandoc-7f814c533988362b341ec64cf2b12a42d745975d.tar.gz
Muse reader: simplify "atStart"
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 06f35b1be..6acc88b3d 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -153,12 +153,11 @@ dropSpacePrefix lns =
where flns = filter (not . all (== ' ')) lns
maxIndent = if null flns then maximum (map length lns) else length $ takeWhile (== ' ') $ foldl1 commonPrefix flns
-atStart :: PandocMonad m => MuseParser m a -> MuseParser m a
-atStart p = do
+atStart :: PandocMonad m => MuseParser m ()
+atStart = do
pos <- getPosition
st <- getState
guard $ museLastStrPos st /= Just pos
- p
firstColumn :: PandocMonad m => MuseParser m ()
firstColumn = getPosition >>= \pos -> guard (sourceColumn pos == 1)
@@ -778,7 +777,8 @@ emphasisBetween :: (PandocMonad m, Show a)
=> MuseParser m a
-> MuseParser m (F Inlines)
emphasisBetween p = try $ trimInlinesF . mconcat
- <$ atStart p
+ <$ atStart
+ <* p
<* notFollowedBy spaceChar
<*> many1Till inline p
<* notFollowedBy alphaNum
@@ -845,7 +845,8 @@ nbsp = try $ pure (B.str "\160") <$ string "~~"
-- | Parse code markup, indicated by @\'=\'@ characters.
code :: PandocMonad m => MuseParser m (F Inlines)
code = try $ fmap pure $ B.code . uncurry (++)
- <$ atStart (char '=')
+ <$ atStart
+ <* char '='
<* notFollowedBy (spaceChar <|> newline)
<*> manyUntil (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) (try $ fmap pure $ noneOf " \t\n\r=" <* char '=')
<* notFollowedBy alphaNum