git.iko.soy/typeable/pandoc
on master help sign in
Org reader: allow multiple, comma-separated authors

Multiple authors can be specified in the `#+AUTHOR` meta line if they are given as a comma-separated list.

commit2ca2585b3569bd14923795f3023bd0789fe7911f authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 29 Aug 2016, 14:10 (10 years ago) parent153970b
2 files changed+17−2
src/Text/Pandoc/Readers/Org/Meta.hs+9−1 tests/Tests/Readers/Org.hs+8−1
src/Text/Pandoc/Readers/Org/Meta.hs+9−1
@@ -69,7 +69,7 @@ metaKey = map toLower <$> many1 (noneOf ": \n\r")
6969metaValue :: String -> OrgParser (F MetaValue)
7070metaValue key = do
7171 case key of
72− "author" -> metaInlines
72+ "author" -> metaInlinesCommaSeparated
7373 "title" -> metaInlines
7474 "date" -> metaInlines
7575 _ -> metaString
@@ -77,6 +77,14 @@ metaValue key = do
7777metaInlines :: OrgParser (F MetaValue)
7878metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
7979
80+metaInlinesCommaSeparated :: OrgParser (F MetaValue)
81+metaInlinesCommaSeparated = do
82+ authStrs <- (many1 (noneOf ",\n")) `sepBy1` (char ',')
83+ newline
84+ authors <- mapM (parseFromString inlinesTillNewline . (++ "\n")) authStrs
85+ let toMetaInlines = MetaInlines . B.toList
86+ return $ MetaList . map toMetaInlines <$> sequence authors
87+
8088metaString :: OrgParser (F MetaValue)
8189metaString = return . MetaString <$> anyLine
8290
tests/Tests/Readers/Org.hs+8−1
@@ -467,7 +467,14 @@ tests =
467467 , "Author" =:
468468 "#+author: Albert /Emacs-Fanboy/ Krewinkel" =?>
469469 let author = toList . spcSep $ [ "Albert", emph "Emacs-Fanboy", "Krewinkel" ]
470− meta = setMeta "author" (MetaInlines author) $ nullMeta
470+ meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta
471+ in Pandoc meta mempty
472+
473+ , "Multiple authors" =:
474+ "#+author: James Dewey Watson, Francis Harry Compton Crick " =?>
475+ let watson = MetaInlines $ toList "James Dewey Watson"
476+ crick = MetaInlines $ toList "Francis Harry Compton Crick"
477+ meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta
471478 in Pandoc meta mempty
472479
473480 , "Date" =: