git.iko.soy/typeable/pandoc
on master help sign in
Org reader: read markup only for special meta keys
153970bAlbert Krewinkel
src/Text/Pandoc/Readers/Org/Meta.hs+20−5
@@ -55,20 +55,35 @@ metaLine = mempty <$ metaLineStart <* (optionLine <|> declarationLine)
55
55
56declarationLine :: OrgParser ()
56declarationLine :: OrgParser ()
57declarationLine = try $ do
57declarationLine = try $ do
58− key <- metaKey
58+ key <- map toLower <$> metaKey
59− value <- metaInlines
59+ value <- metaValue key
60 updateState $ \st ->
60 updateState $ \st ->
61 let meta' = B.setMeta key <$> value <*> pure nullMeta
61 let meta' = B.setMeta key <$> value <*> pure nullMeta
62 in st { orgStateMeta = orgStateMeta st <> meta' }
62 in st { orgStateMeta = orgStateMeta st <> meta' }
63
63
64−metaInlines :: OrgParser (F MetaValue)
65−metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
66−
67metaKey :: OrgParser String
64metaKey :: OrgParser String
68metaKey = map toLower <$> many1 (noneOf ": \n\r")
65metaKey = map toLower <$> many1 (noneOf ": \n\r")
69 <* char ':'
66 <* char ':'
70 <* skipSpaces
67 <* skipSpaces
71
68
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+--
72optionLine :: OrgParser ()
87optionLine :: OrgParser ()
73optionLine = try $ do
88optionLine = try $ do
74 key <- metaKey
89 key <- metaKey
tests/Tests/Readers/Org.hs+2−2
@@ -478,8 +478,8 @@ tests =
478
478
479 , "Description" =:
479 , "Description" =:
480 "#+DESCRIPTION: Explanatory text" =?>
480 "#+DESCRIPTION: Explanatory text" =?>
481− let description = toList . spcSep $ [ "Explanatory", "text" ]
481+ let description = "Explanatory text"
482− meta = setMeta "description" (MetaInlines description) $ nullMeta
482+ meta = setMeta "description" (MetaString description) $ nullMeta
483 in Pandoc meta mempty
483 in Pandoc meta mempty
484
484
485 , "Properties drawer" =:
485 , "Properties drawer" =: