diff options
author | Nikolay Yakimov <root@livid.pp.ru> | 2015-03-28 02:57:33 +0300 |
---|---|---|
committer | Nikolay Yakimov <root@livid.pp.ru> | 2015-03-28 07:05:02 +0300 |
commit | 7091002966bf6cacc6674a195fd03696dc71edf5 (patch) | |
tree | 4c938bd8bda64472183b3823cca6734eed3bb339 | |
parent | 6960b2a4cce65479e15f19369e7c3268d4b8a8a5 (diff) | |
download | pandoc-7091002966bf6cacc6674a195fd03696dc71edf5.tar.gz |
Markdown Reader: Req. " " after key in mmd title block
Require space after key-value delimiter colon in mmd title block.
Issue #2026
Amend: parsec's `spaces` include newlines, but we don't want that. Had
to make custom `spaceNoNewline` parser here
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index bd436da87..9d37808ee 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -35,7 +35,7 @@ import Data.List ( transpose, sortBy, intersperse, intercalate, elemIndex) import qualified Data.Map as M import Data.Scientific (coefficient, base10Exponent) import Data.Ord ( comparing ) -import Data.Char ( isAlphaNum, toLower ) +import Data.Char ( isSpace, isAlphaNum, toLower ) import Data.Maybe import Text.Pandoc.Definition import qualified Data.Text as T @@ -326,11 +326,14 @@ mmdTitleBlock = try $ do kvPair :: MarkdownParser (String, MetaValue) kvPair = try $ do key <- many1Till (alphaNum <|> oneOf "_- ") (char ':') + skipMany1 spaceNoNewline val <- manyTill anyChar (try $ newline >> lookAhead (blankline <|> nonspaceChar)) let key' = concat $ words $ map toLower key let val' = MetaBlocks $ B.toList $ B.plain $ B.text $ trim val return (key',val') + where + spaceNoNewline = satisfy (\x -> isSpace x && (x/='\n') && (x/='\r')) parseMarkdown :: MarkdownParser Pandoc parseMarkdown = do |