diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Meta.hs | 10 | ||||
-rw-r--r-- | tests/Tests/Readers/Org.hs | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs index 8f0b9f6b5..372b19fb6 100644 --- a/src/Text/Pandoc/Readers/Org/Meta.hs +++ b/src/Text/Pandoc/Readers/Org/Meta.hs @@ -69,7 +69,7 @@ metaKey = map toLower <$> many1 (noneOf ": \n\r") metaValue :: String -> OrgParser (F MetaValue) metaValue key = do case key of - "author" -> metaInlines + "author" -> metaInlinesCommaSeparated "title" -> metaInlines "date" -> metaInlines _ -> metaString @@ -77,6 +77,14 @@ metaValue key = do metaInlines :: OrgParser (F MetaValue) metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline +metaInlinesCommaSeparated :: OrgParser (F MetaValue) +metaInlinesCommaSeparated = do + authStrs <- (many1 (noneOf ",\n")) `sepBy1` (char ',') + newline + authors <- mapM (parseFromString inlinesTillNewline . (++ "\n")) authStrs + let toMetaInlines = MetaInlines . B.toList + return $ MetaList . map toMetaInlines <$> sequence authors + metaString :: OrgParser (F MetaValue) metaString = return . MetaString <$> anyLine diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 61c222919..844266401 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -467,7 +467,14 @@ tests = , "Author" =: "#+author: Albert /Emacs-Fanboy/ Krewinkel" =?> let author = toList . spcSep $ [ "Albert", emph "Emacs-Fanboy", "Krewinkel" ] - meta = setMeta "author" (MetaInlines author) $ nullMeta + meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta + in Pandoc meta mempty + + , "Multiple authors" =: + "#+author: James Dewey Watson, Francis Harry Compton Crick " =?> + let watson = MetaInlines $ toList "James Dewey Watson" + crick = MetaInlines $ toList "Francis Harry Compton Crick" + meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta in Pandoc meta mempty , "Date" =: |