aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-05-03 14:42:40 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-05-03 14:42:40 +0000
commitcf081435ff00004188f584b180fc66d8e4fe7a57 (patch)
tree7384ebe89cff1c9c3a105ba1e8cfa9fa17169771
parent485fa81559749f564a56c8b9638c4d03921ba9dd (diff)
downloadpandoc-cf081435ff00004188f584b180fc66d8e4fe7a57.tar.gz
Changed definition list syntax in markdown reader and simplified
the parsing code. A colon is now required before every block in a definition. This fixes a problem with the old syntax, in which the last block in the following was ambiguous between a regular paragraph in the definition and a code block following the definition list: term : definition is this code or more definition? git-svn-id: https://pandoc.googlecode.com/svn/trunk@589 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r--README15
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs19
2 files changed, 16 insertions, 18 deletions
diff --git a/README b/README
index 03bdd4bc3..140819b3a 100644
--- a/README
+++ b/README
@@ -435,21 +435,20 @@ Pandoc supports definition lists, using a syntax inspired by
Term 2
: Definition 2
- Second paragraph of definition 2.
+ : Second paragraph of definition 2.
-The terms must fit on one line, but they may contain arbitrary inline
-markup (emphasis, links, etc.). The definition must begin on the line
-after the term, and must begin with a colon. The definition consists of
-one or more block elements (paragraph, code block, list, etc.).
-Each block must be indented one tab stop.
+Each term must fit on one line. The definition must begin on the line
+after the term. The definition consists of one or more block elements
+(paragraph, code block, list, etc.), each beginning with a colon and
+(aside from the colon) indented one tab stop.
Term *with inline markup*
: Here is the definition. It may
contain multiple blocks. Here is some code:
- {* my code *}
+ : {* my code *}
- Here is the third paragraph of this definition.
+ : Here is the third paragraph of this definition.
If you leave space after the definition (as in the first example above),
the definitions will be considered paragraphs. In some output formats,
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index b6acce62b..05a958090 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -456,27 +456,26 @@ definitionListItem = try $ do
notFollowedBy blankline
notFollowedBy' indentSpaces
term <- manyTill inline newline
- char ':'
+ raw <- many1 defRawBlock
state <- getState
- let tabStop = stateTabStop state
- try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
- firstline <- anyLine
- blanksAfterFirst <- option "" blanklines
- raw <- many defRawBlock
let oldContext = stateParserContext state
- setState $ state {stateParserContext = ListItemState}
-- parse the extracted block, which may contain various block elements:
rest <- getInput
- setInput (concat (firstline:"\n":blanksAfterFirst:raw))
+ setInput (concat raw)
contents <- parseBlocks
setInput rest
updateState (\st -> st {stateParserContext = oldContext})
return ((normalizeSpaces term), contents)
defRawBlock = try $ do
- rawlines <- many1 (do {notFollowedBy' blankline; indentSpaces; anyLine})
+ char ':'
+ state <- getState
+ let tabStop = stateTabStop state
+ try (count (tabStop - 1) (char ' ')) <|> (do{many (char ' '); string "\t"})
+ firstline <- anyLine
+ rawlines <- many (do {notFollowedBy' blankline; indentSpaces; anyLine})
trailing <- option "" blanklines
- return $ (unlines rawlines) ++ trailing
+ return $ firstline ++ "\n" ++ unlines rawlines ++ trailing
definitionList = do
failIfStrict