From 67cb2809fd07d1f14462af2535ce37b8f4e9e464 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel <albert@zeitkraut.de> Date: Fri, 13 Nov 2015 21:25:11 +0100 Subject: [PATCH] Org reader: Require whitespace around def list markers Definition list markers (i.e. double colons `::`) must be surrounded by whitespace to start a definition item. This rule was not checked before, resulting in bugs with footnotes and some link types. Thanks to @conklech for noticing and reporting this issue. This fixes #2518. --- src/Text/Pandoc/Readers/Org.hs | 5 ++++- 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 c04149e1f..44474a37a 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 05d206d85..d956e89e3 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" , ""