aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlexander <ilabdsf@gmail.com>2017-08-22 07:08:44 +0300
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-21 21:08:44 -0700
commit0a839cbdc982217819c08c918cca75f6f56eabbb (patch)
tree30d65e93838c80b8cbcc3c0a434a08f64815a840 /src/Text
parent4567105f6c3574c94a368df7da34bac5643ba624 (diff)
downloadpandoc-0a839cbdc982217819c08c918cca75f6f56eabbb.tar.gz
Muse reader: add definition list support (#3860)
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 5d77dec13..924149294 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -33,7 +33,6 @@ TODO:
- Page breaks (five "*")
- Headings with anchors (make it round trip with Muse writer)
- <verse> and ">"
-- Definition lists
- Org tables
- table.el tables
- Images with attributes (floating and width)
@@ -184,6 +183,7 @@ blockElements = choice [ comment
, quoteTag
, bulletList
, orderedList
+ , definitionList
, table
, commentTag
, noteBlock
@@ -348,6 +348,33 @@ orderedList = try $ do
items <- sequence <$> many1 (listItem $ orderedListStart style delim)
return $ B.orderedListWith p <$> items
+definitionListItem :: PandocMonad m => MuseParser m (F (Inlines, [Blocks]))
+definitionListItem = try $ do
+ term <- termParser
+ many1 spaceChar
+ string "::"
+ firstLine <- anyLineNewline
+ restLines <- manyTill anyLineNewline endOfListItemElement
+ let lns = firstLine : restLines
+ lineContent <- parseFromString (withListContext parseBlocks) $ concat lns ++ "\n"
+ pure $ do lineContent' <- lineContent
+ pure (B.text term, [lineContent'])
+ where
+ termParser = (many1 spaceChar) >> -- Initial space as required by Amusewiki, but not Emacs Muse
+ (many1Till anyChar $ lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
+ endOfInput = try $ skipMany blankline >> skipSpaces >> eof
+ twoBlankLines = try $ blankline >> skipMany1 blankline
+ newDefinitionListItem = try $ void termParser
+ endOfListItemElement = lookAhead $ endOfInput <|> newDefinitionListItem <|> twoBlankLines
+
+definitionListItems :: PandocMonad m => MuseParser m (F [(Inlines, [Blocks])])
+definitionListItems = sequence <$> many1 definitionListItem
+
+definitionList :: PandocMonad m => MuseParser m (F Blocks)
+definitionList = do
+ listItems <- definitionListItems
+ return $ B.definitionList <$> listItems
+
--
-- tables
--