From 63c65c89da7fa54c96199cf88bf1769b7088c1ec Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 21 Jul 2019 23:06:17 +0200 Subject: Org reader: accept ATTR_LATEX in block attributes Attributes for LaTeX output are accepted as valid block attributes; however, their values are ignored. Fixes: #5648 --- src/Text/Pandoc/Readers/Org/Blocks.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 46ddc4257..8ee9c025d 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -115,10 +115,14 @@ stringyMetaAttribute = try $ do attrValue <- anyLine <|> ("" <$ newline) return (attrName, attrValue) +-- | Parse a set of block attributes. Block attributes are given through +-- lines like @#+CAPTION: block caption@ or @#+ATTR_HTML: :width 20@. +-- Parsing will fail if any line contains an attribute different from +-- those attributes known to work on blocks. blockAttributes :: PandocMonad m => OrgParser m BlockAttributes blockAttributes = try $ do kv <- many stringyMetaAttribute - guard $ all (attrCheck . fst) kv + guard $ all (isBlockAttr . fst) kv let caption = foldl' (appendValues "CAPTION") Nothing kv let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv let name = lookup "NAME" kv @@ -134,8 +138,12 @@ blockAttributes = try $ do , blockAttrKeyValues = kvAttrs' } where - attrCheck :: String -> Bool - attrCheck x = x `elem` ["NAME", "LABEL", "CAPTION", "ATTR_HTML", "RESULTS"] + isBlockAttr :: String -> Bool + isBlockAttr = flip elem + [ "NAME", "LABEL", "CAPTION" + , "ATTR_HTML", "ATTR_LATEX" + , "RESULTS" + ] appendValues :: String -> Maybe String -> (String, String) -> Maybe String appendValues attrName accValue (key, value) = -- cgit v1.2.3