From 153970bef5068f5a82943cc7a2bec79f04d31ae9 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:56 +0200 Subject: Org reader: read markup only for special meta keys Most meta-keys should be read as normal string values, only a few are interpreted as marked-up text. --- tests/Tests/Readers/Org.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 0a3f9c222..61c222919 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -478,8 +478,8 @@ tests = , "Description" =: "#+DESCRIPTION: Explanatory text" =?> - let description = toList . spcSep $ [ "Explanatory", "text" ] - meta = setMeta "description" (MetaInlines description) $ nullMeta + let description = "Explanatory text" + meta = setMeta "description" (MetaString description) $ nullMeta in Pandoc meta mempty , "Properties drawer" =: -- cgit v1.2.1 From 2ca2585b3569bd14923795f3023bd0789fe7911f Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: allow multiple, comma-separated authors Multiple authors can be specified in the `#+AUTHOR` meta line if they are given as a comma-separated list. --- tests/Tests/Readers/Org.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 61c222919..844266401 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -467,7 +467,14 @@ tests = , "Author" =: "#+author: Albert /Emacs-Fanboy/ Krewinkel" =?> let author = toList . spcSep $ [ "Albert", emph "Emacs-Fanboy", "Krewinkel" ] - meta = setMeta "author" (MetaInlines author) $ nullMeta + meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta + in Pandoc meta mempty + + , "Multiple authors" =: + "#+author: James Dewey Watson, Francis Harry Compton Crick " =?> + let watson = MetaInlines $ toList "James Dewey Watson" + crick = MetaInlines $ toList "Francis Harry Compton Crick" + meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta in Pandoc meta mempty , "Date" =: -- cgit v1.2.1 From 75df1042157e271398e880e64ce95bd83c5d2193 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: give precedence to later meta lines The last meta-line of any given type is the significant line. Previously the value of the first line was kept, even if more lines of the same type were encounterd. --- tests/Tests/Readers/Org.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 844266401..5bb291d45 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -496,6 +496,14 @@ tests = ] =?> (mempty::Blocks) + , "later meta definitions take precedence" =: + unlines [ "#+AUTHOR: this will not be used" + , "#+author: Max" + ] =?> + let author = MetaInlines [Str "Max"] + meta = setMeta "author" (MetaList [author]) $ nullMeta + in Pandoc meta mempty + , "Logbook drawer" =: unlines [ " :LogBook:" , " - State \"DONE\" from \"TODO\" [2014-03-03 Mon 11:00]" -- cgit v1.2.1 From a2574883432c2375661caa4bee19a48967cf49db Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: read LaTeX_header as header-includes LaTeX-specific header commands can be defined in `#+LaTeX_header` lines. They are parsed as format-specific inlines to ensure that they will only show up in LaTeX output. --- tests/Tests/Readers/Org.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 5bb291d45..a3f6f73e4 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -496,6 +496,13 @@ tests = ] =?> (mempty::Blocks) + , "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 + , "later meta definitions take precedence" =: unlines [ "#+AUTHOR: this will not be used" , "#+author: Max" -- cgit v1.2.1 From 825ce8ca73073db3a1bf0db1ece9fe0344a2e8ab Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: set documentclass meta from LaTeX_class --- tests/Tests/Readers/Org.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index a3f6f73e4..2af019469 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -503,6 +503,11 @@ tests = meta = setMeta "header-includes" inclList nullMeta in Pandoc meta mempty + , "LaTeX_class option is translated to documentclass" =: + "#+LATEX_CLASS: article" =?> + let meta = setMeta "documentclass" (MetaString "article") nullMeta + in Pandoc meta mempty + , "later meta definitions take precedence" =: unlines [ "#+AUTHOR: this will not be used" , "#+author: Max" -- cgit v1.2.1 From d164ead37900a186acad44bb244f9268d3e3e91d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: set classoption meta from LaTeX_class_options --- tests/Tests/Readers/Org.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 2af019469..534990876 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -508,6 +508,11 @@ tests = let meta = setMeta "documentclass" (MetaString "article") 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 + , "later meta definitions take precedence" =: unlines [ "#+AUTHOR: this will not be used" , "#+author: Max" -- cgit v1.2.1 From 28d17ea70fee316576cf28525e9b5ad15c62cf9d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Org reader: read HTML_head as header-includes HTML-specific head content can be defined in `#+HTML_head` lines. They are parsed as format-specific inlines to ensure that they will only show up in HTML output. --- tests/Tests/Readers/Org.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 534990876..524bed109 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -513,6 +513,13 @@ tests = let meta = setMeta "classoption" (MetaString "a4paper") nullMeta in Pandoc meta mempty + , "LaTeX_class_options is translated to classoption" =: + "#+html_head: " =?> + let html = rawInline "html" "" + inclList = MetaList [MetaInlines (toList html)] + meta = setMeta "header-includes" inclList nullMeta + in Pandoc meta mempty + , "later meta definitions take precedence" =: unlines [ "#+AUTHOR: this will not be used" , "#+author: Max" -- cgit v1.2.1 From ad625782b170f4cbbef206bc6ea736c082cb38d7 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:57 +0200 Subject: Put Org reader export option tests into test group Using a separate test group instead of prefixing the test subject should be clearer than the current approach. --- tests/Tests/Readers/Org.hs | 126 +++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 61 deletions(-) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 524bed109..9979dc8ec 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -602,69 +602,73 @@ tests = ] =?> (para (link "http://example.com/foo" "" "bar")) - , "Export option: Disable simple sub/superscript syntax" =: - unlines [ "#+OPTIONS: ^:nil" - , "a^b" - ] =?> - para "a^b" - - , "Export option: directly select drawers to be exported" =: - unlines [ "#+OPTIONS: d:(\"IMPORTANT\")" - , ":IMPORTANT:" - , "23" - , ":END:" - , ":BORING:" - , "very boring" - , ":END:" - ] =?> - divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "23") - - , "Export option: exclude drawers from being exported" =: - unlines [ "#+OPTIONS: d:(not \"BORING\")" - , ":IMPORTANT:" - , "5" - , ":END:" - , ":BORING:" - , "very boring" - , ":END:" - ] =?> - divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "5") - - , "Export option: don't include archive trees" =: - unlines [ "#+OPTIONS: arch:nil" - , "* old :ARCHIVE:" - ] =?> - (mempty ::Blocks) - , "Export option: include complete archive trees" =: - unlines [ "#+OPTIONS: arch:t" - , "* old :ARCHIVE:" - , " boring" - ] =?> - let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty - in mconcat [ headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE") - , para "boring" - ] + , testGroup "export options" + + [ "disable simple sub/superscript syntax" =: + unlines [ "#+OPTIONS: ^:nil" + , "a^b" + ] =?> + para "a^b" + + , "directly select drawers to be exported" =: + unlines [ "#+OPTIONS: d:(\"IMPORTANT\")" + , ":IMPORTANT:" + , "23" + , ":END:" + , ":BORING:" + , "very boring" + , ":END:" + ] =?> + divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "23") + + , "exclude drawers from being exported" =: + unlines [ "#+OPTIONS: d:(not \"BORING\")" + , ":IMPORTANT:" + , "5" + , ":END:" + , ":BORING:" + , "very boring" + , ":END:" + ] =?> + divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "5") + + , "don't include archive trees" =: + unlines [ "#+OPTIONS: arch:nil" + , "* old :ARCHIVE:" + ] =?> + (mempty ::Blocks) + + , "include complete archive trees" =: + unlines [ "#+OPTIONS: arch:t" + , "* old :ARCHIVE:" + , " boring" + ] =?> + let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty + in mconcat [ headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE") + , para "boring" + ] - , "Export option: include archive tree header only" =: - unlines [ "#+OPTIONS: arch:headline" - , "* old :ARCHIVE:" - , " boring" - ] =?> - let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty - in headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE") - - , "Export option: limit headline depth" =: - unlines [ "#+OPTIONS: H:2" - , "* section" - , "** subsection" - , "*** list item 1" - , "*** list item 2" - ] =?> - mconcat [ headerWith ("section", [], []) 1 "section" - , headerWith ("subsection", [], []) 2 "subsection" - , orderedList [ para "list item 1", para "list item 2" ] - ] + , "include archive tree header only" =: + unlines [ "#+OPTIONS: arch:headline" + , "* old :ARCHIVE:" + , " boring" + ] =?> + let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty + in headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE") + + , "limit headline depth" =: + unlines [ "#+OPTIONS: H:2" + , "* section" + , "** subsection" + , "*** list item 1" + , "*** list item 2" + ] =?> + mconcat [ headerWith ("section", [], []) 1 "section" + , headerWith ("subsection", [], []) 2 "subsection" + , orderedList [ para "list item 1", para "list item 2" ] + ] + ] ] , testGroup "Basic Blocks" $ -- cgit v1.2.1 From 117d3f4d92d5096cfa51305db6d2fa261ef87d24 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:58 +0200 Subject: Org reader: respect `author` export option The `author` option controls whether the author should be included in the final markup. Setting `#+OPTIONS: author:nil` will drop the author from the final meta-data output. --- tests/Tests/Readers/Org.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 9979dc8ec..2ef847f30 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -668,6 +668,12 @@ tests = , headerWith ("subsection", [], []) 2 "subsection" , orderedList [ para "list item 1", para "list item 2" ] ] + + , "disable author export" =: + unlines [ "#+OPTIONS: author:nil" + , "#+AUTHOR: ShyGuy" + ] =?> + Pandoc nullMeta mempty ] ] -- cgit v1.2.1 From 0568aa5cad5ca5501dc0565b0e341fc5393f67e2 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:58 +0200 Subject: Org reader: respect `email` export option The `email` option controls whether the email meta-field should be included in the final markup. Setting `#+OPTIONS: email:nil` will drop the email field from the final meta-data output. --- tests/Tests/Readers/Org.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 2ef847f30..5191f63d5 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -674,6 +674,12 @@ tests = , "#+AUTHOR: ShyGuy" ] =?> Pandoc nullMeta mempty + + , "disable email export" =: + unlines [ "#+OPTIONS: email:nil" + , "#+email: no-mail-please@example.com" + ] =?> + Pandoc nullMeta mempty ] ] -- cgit v1.2.1 From 88313c0b93694e310175a461ed74f497debbd57d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:58 +0200 Subject: Org reader: respect `creator` export option The `creator` option controls whether the creator meta-field should be included in the final markup. Setting `#+OPTIONS: creator:nil` will drop the creator field from the final meta-data output. Org-mode recognizes the special value `comment` for this field, causing the creator to be included in a comment. This is difficult to translate to Pandoc internals and is hence interpreted the same as other truish values (i.e. the meta field is kept if it's present). --- tests/Tests/Readers/Org.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/Tests/Readers/Org.hs') diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index 5191f63d5..d6e7bba22 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -675,6 +675,12 @@ tests = ] =?> Pandoc nullMeta mempty + , "disable creator export" =: + unlines [ "#+OPTIONS: creator:nil" + , "#+creator: The Architect" + ] =?> + Pandoc nullMeta mempty + , "disable email export" =: unlines [ "#+OPTIONS: email:nil" , "#+email: no-mail-please@example.com" -- cgit v1.2.1