diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Readers/Org/Meta.hs | 182 |
1 files changed, 110 insertions, 72 deletions
diff --git a/test/Tests/Readers/Org/Meta.hs b/test/Tests/Readers/Org/Meta.hs index c811f2363..0bd63b15d 100644 --- a/test/Tests/Readers/Org/Meta.hs +++ b/test/Tests/Readers/Org/Meta.hs @@ -93,6 +93,13 @@ tests = in Pandoc meta mempty ] + , "Subtitle" =: + T.unlines [ "#+SUBTITLE: Your Life in" + , "#+SUBTITLE: /Plain/ Text" + ] =?> + let subtitle = "Your Life in" <> softbreak <> emph "Plain" <> " Text" + in Pandoc (setMeta "subtitle" (toMetaValue subtitle) nullMeta) mempty + , "Keywords" =: T.unlines [ "#+KEYWORDS: pandoc, testing," , "#+KEYWORDS: Org" @@ -101,42 +108,117 @@ tests = meta = setMeta "keywords" (MetaInlines keywords) nullMeta in Pandoc meta mempty - , "LaTeX_headers options are translated to header-includes" =: - "#+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 + , "Institute" =: + "#+INSTITUTE: ACME Inc." =?> + Pandoc (setMeta "institute" ("ACME Inc." :: Inlines) nullMeta) mempty - , testGroup "LaTeX_CLASS" - [ "LaTeX_class option is translated to documentclass" =: - "#+LATEX_CLASS: article" =?> - let meta = setMeta "documentclass" (MetaString "article") nullMeta + , testGroup "LaTeX" + [ "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 - , "last definition takes precedence" =: - T.unlines [ "#+LATEX_CLASS: this will not be used" - , "#+LATEX_CLASS: report" - ] =?> - let meta = setMeta "documentclass" (MetaString "report") nullMeta + , "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" + [ "stored as documentclass" =: + "#+LATEX_CLASS: article" =?> + let meta = setMeta "documentclass" (MetaString "article") nullMeta + in Pandoc meta mempty + + , "last definition takes precedence" =: + T.unlines [ "#+LATEX_CLASS: this will not be used" + , "#+LATEX_CLASS: report" + ] =?> + let meta = setMeta "documentclass" (MetaString "report") nullMeta + in Pandoc meta mempty + ] + + , "LATEX_CLASS_OPTIONS as classoption" =: + "#+LATEX_CLASS_OPTIONS: [a4paper]" =?> + let meta = setMeta "classoption" (MetaString "a4paper") nullMeta in Pandoc meta mempty ] - , "LaTeX_class_options is translated to classoption" =: - "#+LATEX_CLASS_OPTIONS: [a4paper]" =?> - let meta = setMeta "classoption" (MetaString "a4paper") nullMeta - in Pandoc meta mempty + , testGroup "HTML" + [ "HTML_HEAD values are added to header-includes" =: + "#+html_head: <meta/>" =?> + let html = rawInline "html" "<meta/>" + inclList = MetaList [MetaInlines (toList html)] + meta = setMeta "header-includes" inclList nullMeta + in Pandoc meta mempty - , "LaTeX_class_options is translated to classoption" =: - "#+html_head: <meta/>" =?> - let html = rawInline "html" "<meta/>" - inclList = MetaList [MetaInlines (toList html)] - meta = setMeta "header-includes" inclList nullMeta - in Pandoc meta mempty + , "HTML_HEAD_EXTRA behaves like HTML_HEAD" =: + T.unlines [ "#+HTML_HEAD: <meta name=\"generator\" content=\"pandoc\">" + , "#+HTML_HEAD_EXTRA: <meta charset=\"utf-8\">" + ] =?> + let generator = rawInline "html" + "<meta name=\"generator\" content=\"pandoc\">" + charset = rawInline "html" "<meta charset=\"utf-8\">" + inclList = toMetaValue [generator, charset] + in Pandoc (setMeta "header-includes" inclList nullMeta) mempty + ] + ] - , "Institute" =: - "#+INSTITUTE: ACME Inc." =?> - Pandoc (setMeta "institute" ("ACME Inc." :: Inlines) nullMeta) mempty + , 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" =: + T.unlines [ "#+UNKNOWN_KEYWORD: Chumbawamba" + , "#+ANOTHER_UNKNOWN: Blur" + ] =?> + rawBlock "org" "#+UNKNOWN_KEYWORD: Chumbawamba" <> + rawBlock "org" "#+ANOTHER_UNKNOWN: Blur" ] , "Properties drawer" =: @@ -193,48 +275,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/]" - ] ] |