Muse reader: move indentation parsing from definitionListItem to definitionList

This commit is contained in:
Alexander Krotov 2018-02-12 14:56:39 +03:00
parent 3480a8acc2
commit 10c8b9f4bb

View file

@ -529,9 +529,8 @@ orderedList = try $ do
rest <- many $ listItem (col - 1) (museOrderedListMarker style) rest <- many $ listItem (col - 1) (museOrderedListMarker style)
return $ B.orderedListWith p <$> sequence (first : rest) return $ B.orderedListWith p <$> sequence (first : rest)
definitionListItem :: PandocMonad m => Int -> MuseParser m (F (Inlines, [Blocks])) definitionListItem :: PandocMonad m => MuseParser m (F (Inlines, [Blocks]))
definitionListItem n = try $ do definitionListItem = try $ do
count n spaceChar
pos <- getPosition pos <- getPosition
term <- trimInlinesF . mconcat <$> manyTill (choice inlineList) (string "::") term <- trimInlinesF . mconcat <$> manyTill (choice inlineList) (string "::")
void spaceChar <|> lookAhead eol void spaceChar <|> lookAhead eol
@ -544,9 +543,10 @@ definitionList :: PandocMonad m => MuseParser m (F Blocks)
definitionList = try $ do definitionList = try $ do
many spaceChar many spaceChar
pos <- getPosition pos <- getPosition
guardDisabled Ext_amuse <|> guard (sourceColumn pos /= 1) -- Initial space is required by Amusewiki, but not Emacs Muse let indent = sourceColumn pos - 1
first <- definitionListItem 0 guardDisabled Ext_amuse <|> guard (indent /= 0) -- Initial space is required by Amusewiki, but not Emacs Muse
rest <- many $ try (optional blankline >> definitionListItem (sourceColumn pos - 1)) first <- definitionListItem
rest <- many $ try (optional blankline >> count indent spaceChar >> definitionListItem)
return $ B.definitionList <$> sequence (first : rest) return $ B.definitionList <$> sequence (first : rest)
-- --