diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-11-13 14:07:56 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-11-13 14:07:56 -0800 |
commit | 73e6333faeb42197c25a47a4aaa3b2c17edec117 (patch) | |
tree | 389e4176d039ed72a5f7dff356e83a8e36f2d164 | |
parent | c65674a33169bee1e4f8f1e7adbd511c750ecd40 (diff) | |
parent | 67cb2809fd07d1f14462af2535ce37b8f4e9e464 (diff) | |
download | pandoc-73e6333faeb42197c25a47a4aaa3b2c17edec117.tar.gz |
Merge pull request #2526 from tarleb/org-definition-lists-fix
Org reader: Require whitespace around def list markers
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 5 | ||||
-rw-r--r-- | tests/Tests/Readers/Org.hs | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index 376624fb3..3be47cfd4 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -994,13 +994,16 @@ definitionListItem :: OrgParser Int -> OrgParser (F (Inlines, [Blocks])) definitionListItem parseMarkerGetLength = try $ do markerLength <- parseMarkerGetLength - term <- manyTill (noneOf "\n\r") (try $ string "::") + term <- manyTill (noneOf "\n\r") (try definitionMarker) line1 <- anyLineNewline blank <- option "" ("\n" <$ blankline) cont <- concat <$> many (listContinuation markerLength) term' <- parseFromString parseInlines term contents' <- parseFromString parseBlocks $ line1 ++ blank ++ cont return $ (,) <$> term' <*> fmap (:[]) contents' + where + definitionMarker = + spaceChar *> string "::" <* (spaceChar <|> lookAhead P.newline) -- parse raw text for one list item, excluding start marker and continuations diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 02d2fb696..9e7399aa0 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -841,7 +841,7 @@ tests = unlines [ "- PLL :: phase-locked loop" , "- TTL ::" , " transistor-transistor logic" - , "- PSK::phase-shift keying" + , "- PSK :: phase-shift keying" , "" , " a digital modulation scheme" ] =?> @@ -880,6 +880,10 @@ tests = , headerWith ("header", [], []) 1 "header" ] + , "Definition lists double-colon markers must be surrounded by whitespace" =: + "- std::cout" =?> + bulletList [ plain "std::cout" ] + , "Loose bullet list" =: unlines [ "- apple" , "" |