git.iko.soy/typeable/pandoc
on master help sign in
Org reader: set classoption meta from LaTeX_class_options
commitd164ead37900a186acad44bb244f9268d3e3e91d authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 29 Aug 2016, 14:10 (10 years ago) parent825ce8c
2 files changed+13−1
src/Text/Pandoc/Readers/Org/Meta.hs+8−1 tests/Tests/Readers/Org.hs+5
src/Text/Pandoc/Readers/Org/Meta.hs+8−1
@@ -78,6 +78,10 @@ metaValue key =
7878 "latex_header" -> (inclKey,) <$>
7979 accumulatingList inclKey (metaExportSnippet "latex")
8080 "latex_class" -> ("documentclass",) <$> metaString
81+ -- Org-mode expects class options to contain the surrounding brackets,
82+ -- pandoc does not.
83+ "latex_class_options" -> ("classoption",) <$>
84+ metaModifiedString (filter (`notElem` "[]"))
8185 _ -> (key,) <$> metaString
8286
8387metaInlines :: OrgParser (F MetaValue)
@@ -92,7 +96,10 @@ metaInlinesCommaSeparated = do
9296 return $ MetaList . map toMetaInlines <$> sequence authors
9397
9498metaString :: OrgParser (F MetaValue)
95−metaString = return . MetaString <$> anyLine
99+metaString = metaModifiedString id
100+
101+metaModifiedString :: (String -> String) -> OrgParser (F MetaValue)
102+metaModifiedString f = return . MetaString . f <$> anyLine
96103
97104-- | Read an format specific meta definition
98105metaExportSnippet :: String -> OrgParser (F MetaValue)
tests/Tests/Readers/Org.hs+5
@@ -508,6 +508,11 @@ tests =
508508 let meta = setMeta "documentclass" (MetaString "article") nullMeta
509509 in Pandoc meta mempty
510510
511+ , "LaTeX_class_options is translated to classoption" =:
512+ "#+LATEX_CLASS_OPTIONS: [a4paper]" =?>
513+ let meta = setMeta "classoption" (MetaString "a4paper") nullMeta
514+ in Pandoc meta mempty
515+
511516 , "later meta definitions take precedence" =:
512517 unlines [ "#+AUTHOR: this will not be used"
513518 , "#+author: Max"