diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-25 22:32:11 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-25 22:32:50 -0700 |
commit | 243c56a880054bc11ee2007f9ab77174fff1d40f (patch) | |
tree | 4ab572c7c46374139ccafee8d445864aa9c6a9cc /src/Text/Pandoc/Readers | |
parent | 70eeeb82b5956387e5fd4002353655e8199edf62 (diff) | |
download | pandoc-243c56a880054bc11ee2007f9ab77174fff1d40f.tar.gz |
Fixed 'authors' metadata parsing in reST.
Semicolons separate different authors.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 0829996a7..34962b553 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -109,8 +109,29 @@ titleTransform (bs, meta) = _ -> (bs', meta') metaFromDefList :: [([Inline], [[Block]])] -> Meta -> Meta -metaFromDefList ds meta = foldr f meta ds +metaFromDefList ds meta = adjustAuthors $ foldr f meta ds where f (k,v) = setMeta (map toLower $ stringify k) (mconcat $ map fromList v) + adjustAuthors (Meta metamap) = Meta $ M.adjust toPlain "author" + $ M.adjust toPlain "date" + $ M.adjust toPlain "title" + $ M.adjust splitAuthors "authors" + $ metamap + toPlain (MetaBlocks [Para xs]) = MetaInlines xs + toPlain x = x + splitAuthors (MetaBlocks [Para xs]) = MetaList $ map MetaInlines + $ splitAuthors' xs + splitAuthors x = x + splitAuthors' = map normalizeSpaces . + splitOnSemi . concatMap factorSemi + splitOnSemi = splitBy (==Str ";") + factorSemi (Str []) = [] + factorSemi (Str s) = case break (==';') s of + (xs,[]) -> [Str xs] + (xs,';':ys) -> Str xs : Str ";" : + factorSemi (Str ys) + (xs,ys) -> Str xs : + factorSemi (Str ys) + factorSemi x = [x] parseRST :: RSTParser Pandoc parseRST = do |