git.iko.soy/typeable/pandoc
on master help sign in
Org reader: read markup only for special meta keys

Most meta-keys should be read as normal string values, only a few are interpreted as marked-up text.

commit153970bef5068f5a82943cc7a2bec79f04d31ae9 authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 29 Aug 2016, 14:10 (10 years ago) parentbed5f70
2 files changed+22−7
src/Text/Pandoc/Readers/Org/Meta.hs+20−5 tests/Tests/Readers/Org.hs+2−2
src/Text/Pandoc/Readers/Org/Meta.hs+20−5
@@ -55,20 +55,35 @@ metaLine = mempty <$ metaLineStart <* (optionLine <|> declarationLine)
5555
5656declarationLine :: OrgParser ()
5757declarationLine = try $ do
58− key <- metaKey
59− value <- metaInlines
58+ key <- map toLower <$> metaKey
59+ value <- metaValue key
6060 updateState $ \st ->
6161 let meta' = B.setMeta key <$> value <*> pure nullMeta
6262 in st { orgStateMeta = orgStateMeta st <> meta' }
6363
64−metaInlines :: OrgParser (F MetaValue)
65−metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
66−
6764metaKey :: OrgParser String
6865metaKey = map toLower <$> many1 (noneOf ": \n\r")
6966 <* char ':'
7067 <* skipSpaces
7168
69+metaValue :: String -> OrgParser (F MetaValue)
70+metaValue key = do
71+ case key of
72+ "author" -> metaInlines
73+ "title" -> metaInlines
74+ "date" -> metaInlines
75+ _ -> metaString
76+
77+metaInlines :: OrgParser (F MetaValue)
78+metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
79+
80+metaString :: OrgParser (F MetaValue)
81+metaString = return . MetaString <$> anyLine
82+
83+
84+--
85+-- export options
86+--
7287optionLine :: OrgParser ()
7388optionLine = try $ do
7489 key <- metaKey
tests/Tests/Readers/Org.hs+2−2
@@ -478,8 +478,8 @@ tests =
478478
479479 , "Description" =:
480480 "#+DESCRIPTION: Explanatory text" =?>
481− let description = toList . spcSep $ [ "Explanatory", "text" ]
482− meta = setMeta "description" (MetaInlines description) $ nullMeta
481+ let description = "Explanatory text"
482+ meta = setMeta "description" (MetaString description) $ nullMeta
483483 in Pandoc meta mempty
484484
485485 , "Properties drawer" =: