diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2019-07-21 23:06:17 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2019-07-22 08:12:22 +0200 |
commit | 63c65c89da7fa54c96199cf88bf1769b7088c1ec (patch) | |
tree | 656f57a2b47160a4438ffc7ee4d4579b76df1de1 /src | |
parent | 91d4283263cc648efdd41e8c391477dd962db8ce (diff) | |
download | pandoc-63c65c89da7fa54c96199cf88bf1769b7088c1ec.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 14 |
1 files changed, 11 insertions, 3 deletions
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) = |