From 90ac70c79c776a0f41367a6f509d66591aa925ae Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Jun 2020 20:21:56 +0200 Subject: Org reader: unify keyword handling Handling of export settings and other keywords (like `#+LINK`) has been combined and unified. --- test/Tests/Readers/Org/Meta.hs | 104 ++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 48 deletions(-) (limited to 'test') diff --git a/test/Tests/Readers/Org/Meta.hs b/test/Tests/Readers/Org/Meta.hs index dd51cbd48..bbbb553ba 100644 --- a/test/Tests/Readers/Org/Meta.hs +++ b/test/Tests/Readers/Org/Meta.hs @@ -113,21 +113,21 @@ tests = Pandoc (setMeta "institute" ("ACME Inc." :: Inlines) nullMeta) mempty , testGroup "LaTeX" - [ "LaTeX_headers options are translated to header-includes" =: + [ "LATEX_HEADER" =: "#+LaTeX_header: \\usepackage{tikz}" =?> let latexInlines = rawInline "latex" "\\usepackage{tikz}" inclList = MetaList [MetaInlines (toList latexInlines)] meta = setMeta "header-includes" inclList nullMeta in Pandoc meta mempty - , "LATEX_HEADER_EXTRA values are translated to header-includes" =: + , "LATEX_HEADER_EXTRA" =: "#+LATEX_HEADER_EXTRA: \\usepackage{calc}" =?> let latexInlines = rawInline "latex" "\\usepackage{calc}" inclList = toMetaValue [latexInlines] in Pandoc (setMeta "header-includes" inclList nullMeta) mempty , testGroup "LaTeX_CLASS" - [ "LaTeX_class option is translated to documentclass" =: + [ "stored as documentclass" =: "#+LATEX_CLASS: article" =?> let meta = setMeta "documentclass" (MetaString "article") nullMeta in Pandoc meta mempty @@ -140,7 +140,7 @@ tests = in Pandoc meta mempty ] - , "LaTeX_class_options is translated to classoption" =: + , "LATEX_CLASS_OPTIONS as classoption" =: "#+LATEX_CLASS_OPTIONS: [a4paper]" =?> let meta = setMeta "classoption" (MetaString "a4paper") nullMeta in Pandoc meta mempty @@ -166,6 +166,58 @@ tests = ] ] + , testGroup "Non-export keywords" + [ testGroup "#+LINK" + [ "Link abbreviation" =: + T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s" + , "[[wp:Org_mode][Wikipedia on Org-mode]]" + ] =?> + para (link "https://en.wikipedia.org/wiki/Org_mode" "" + ("Wikipedia" <> space <> "on" <> space <> "Org-mode")) + + , "Link abbreviation, defined after first use" =: + T.unlines [ "[[zl:non-sense][Non-sense articles]]" + , "#+LINK: zl http://zeitlens.com/tags/%s.html" + ] =?> + para (link "http://zeitlens.com/tags/non-sense.html" "" + ("Non-sense" <> space <> "articles")) + + , "Link abbreviation, URL encoded arguments" =: + T.unlines [ "#+link: expl http://example.com/%h/foo" + , "[[expl:Hello, World!][Moin!]]" + ] =?> + para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!") + + , "Link abbreviation, append arguments" =: + T.unlines [ "#+link: expl http://example.com/" + , "[[expl:foo][bar]]" + ] =?> + para (link "http://example.com/foo" "" "bar") + ] + + , testGroup "emphasis config" + [ "Changing pre and post chars for emphasis" =: + T.unlines [ "#+pandoc-emphasis-pre: \"[)\"" + , "#+pandoc-emphasis-post: \"]\\n\"" + , "([/emph/])*foo*" + ] =?> + para ("([" <> emph "emph" <> "])" <> strong "foo") + + , "setting an invalid value restores the default" =: + T.unlines [ "#+pandoc-emphasis-pre: \"[\"" + , "#+pandoc-emphasis-post: \"]\"" + , "#+pandoc-emphasis-pre:" + , "#+pandoc-emphasis-post:" + , "[/noemph/]" + ] =?> + para "[/noemph/]" + ] + + , "Unknown keyword" =: + "#+UNKNOWN_KEYWORD: Chumbawamba" =?> + Pandoc nullMeta mempty + ] + , "Properties drawer" =: T.unlines [ " :PROPERTIES:" , " :setting: foo" @@ -220,48 +272,4 @@ tests = ] =?> (para (spanWith ("link-here", [], []) mempty <> "Target.") <> para (emph ("See" <> space <> "here!"))) - - , "Link abbreviation" =: - T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s" - , "[[wp:Org_mode][Wikipedia on Org-mode]]" - ] =?> - para (link "https://en.wikipedia.org/wiki/Org_mode" "" - ("Wikipedia" <> space <> "on" <> space <> "Org-mode")) - - , "Link abbreviation, defined after first use" =: - T.unlines [ "[[zl:non-sense][Non-sense articles]]" - , "#+LINK: zl http://zeitlens.com/tags/%s.html" - ] =?> - para (link "http://zeitlens.com/tags/non-sense.html" "" - ("Non-sense" <> space <> "articles")) - - , "Link abbreviation, URL encoded arguments" =: - T.unlines [ "#+link: expl http://example.com/%h/foo" - , "[[expl:Hello, World!][Moin!]]" - ] =?> - para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!") - - , "Link abbreviation, append arguments" =: - T.unlines [ "#+link: expl http://example.com/" - , "[[expl:foo][bar]]" - ] =?> - para (link "http://example.com/foo" "" "bar") - - , testGroup "emphasis config" - [ "Changing pre and post chars for emphasis" =: - T.unlines [ "#+pandoc-emphasis-pre: \"[)\"" - , "#+pandoc-emphasis-post: \"]\\n\"" - , "([/emph/])*foo*" - ] =?> - para ("([" <> emph "emph" <> "])" <> strong "foo") - - , "setting an invalid value restores the default" =: - T.unlines [ "#+pandoc-emphasis-pre: \"[\"" - , "#+pandoc-emphasis-post: \"]\"" - , "#+pandoc-emphasis-pre:" - , "#+pandoc-emphasis-post:" - , "[/noemph/]" - ] =?> - para "[/noemph/]" - ] ] -- cgit v1.2.3