git.iko.soy/typeable/pandoc
on master help sign in
Org reader: set classoption meta from LaTeX_class_options
d164eadAlbert Krewinkel
src/Text/Pandoc/Readers/Org/Meta.hs+8−1
@@ -78,6 +78,10 @@ metaValue key =
78 "latex_header" -> (inclKey,) <$>
78 "latex_header" -> (inclKey,) <$>
79 accumulatingList inclKey (metaExportSnippet "latex")
79 accumulatingList inclKey (metaExportSnippet "latex")
80 "latex_class" -> ("documentclass",) <$> metaString
80 "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` "[]"))
81 _ -> (key,) <$> metaString
85 _ -> (key,) <$> metaString
82
86
83metaInlines :: OrgParser (F MetaValue)
87metaInlines :: OrgParser (F MetaValue)
@@ -92,7 +96,10 @@ metaInlinesCommaSeparated = do
92 return $ MetaList . map toMetaInlines <$> sequence authors
96 return $ MetaList . map toMetaInlines <$> sequence authors
93
97
94metaString :: OrgParser (F MetaValue)
98metaString :: OrgParser (F MetaValue)
99+metaString = metaModifiedString id
100+
101+metaModifiedString :: (String -> String) -> OrgParser (F MetaValue)
95−metaString = return . MetaString <$> anyLine
102+metaModifiedString f = return . MetaString . f <$> anyLine
96
103
97-- | Read an format specific meta definition
104-- | Read an format specific meta definition
98metaExportSnippet :: String -> OrgParser (F MetaValue)
105metaExportSnippet :: String -> OrgParser (F MetaValue)
tests/Tests/Readers/Org.hs+5
@@ -508,6 +508,11 @@ tests =
508 let meta = setMeta "documentclass" (MetaString "article") nullMeta
508 let meta = setMeta "documentclass" (MetaString "article") nullMeta
509 in Pandoc meta mempty
509 in Pandoc meta mempty
510
510
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+
511 , "later meta definitions take precedence" =:
516 , "later meta definitions take precedence" =:
512 unlines [ "#+AUTHOR: this will not be used"
517 unlines [ "#+AUTHOR: this will not be used"
513 , "#+author: Max"
518 , "#+author: Max"