git.iko.soy/typeable/pandoc
on master help sign in
Org tests: group export settings test for Org reader
commitb7a8620b43b8e73ef3be42f607dd7f46e9027634 authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 28 Jun 2020, 18:13 (6 years ago) parenta7d7c29
1 file changed+79−74
test/Tests/Readers/Org/Meta.hs+79−74
test/Tests/Readers/Org/Meta.hs+79−74
@@ -23,15 +23,16 @@ import qualified Data.Text as T
2323
2424tests :: [TestTree]
2525tests =
26− [ "Comment" =:
26+ [ testGroup "Comments"
27+ [ "Comment" =:
2728 "# Nothing to see here" =?>
2829 (mempty::Blocks)
2930
30− , "Not a comment" =:
31+ , "Hash not followed by space is text" =:
3132 "#-tag" =?>
3233 para "#-tag"
3334
34− , "Comment surrounded by Text" =:
35+ , "Comment surrounded by Text" =:
3536 T.unlines [ "Before"
3637 , "# Comment"
3738 , "After"
@@ -39,103 +40,107 @@ tests =
3940 mconcat [ para "Before"
4041 , para "After"
4142 ]
43+ ]
4244
43− , "Title" =:
44− "#+TITLE: Hello, World" =?>
45− let titleInline = toList $ "Hello," <> space <> "World"
46− meta = setMeta "title" (MetaInlines titleInline) nullMeta
47− in Pandoc meta mempty
48−
49− , testGroup "Author"
50− [ "sets 'author' field" =:
51− "#+author: John /Emacs-Fanboy/ Doe" =?>
52− let author = toList . spcSep $ [ "John", emph "Emacs-Fanboy", "Doe" ]
53− meta = setMeta "author" (MetaInlines author) nullMeta
45+ , testGroup "Export settings"
46+ [ "Title" =:
47+ "#+TITLE: Hello, World" =?>
48+ let titleInline = toList $ "Hello," <> space <> "World"
49+ meta = setMeta "title" (MetaInlines titleInline) nullMeta
5450 in Pandoc meta mempty
5551
56− , "Multiple author lines" =:
57− T.unlines [ "#+author: James Dewey Watson,"
58− , "#+author: Francis Harry Compton Crick"
59− ] =?>
60− let watson = toList "James Dewey Watson,"
61− crick = toList "Francis Harry Compton Crick"
62− meta = setMeta "author"
63− (MetaInlines (watson ++ SoftBreak : crick))
64− nullMeta
65− in Pandoc meta mempty
66− ]
52+ , testGroup "Author"
53+ [ "sets 'author' field" =:
54+ "#+author: John /Emacs-Fanboy/ Doe" =?>
55+ let author = toList . spcSep $ [ "John", emph "Emacs-Fanboy", "Doe" ]
56+ meta = setMeta "author" (MetaInlines author) nullMeta
57+ in Pandoc meta mempty
6758
68− , "Date" =:
69− "#+Date: Feb. *28*, 2014" =?>
70− let date = toList . spcSep $ [ "Feb.", strong "28" <> ",", "2014" ]
71− meta = setMeta "date" (MetaInlines date) nullMeta
72− in Pandoc meta mempty
73−
74− , testGroup "Description"
75− [ "Single line" =:
76− "#+DESCRIPTION: Explanatory text" =?>
77− let description = [Str "Explanatory", Space, Str "text"]
78− meta = setMeta "description" (MetaInlines description) nullMeta
59+ , "Multiple author lines" =:
60+ T.unlines [ "#+author: James Dewey Watson,"
61+ , "#+author: Francis Harry Compton Crick"
62+ ] =?>
63+ let watson = toList "James Dewey Watson,"
64+ crick = toList "Francis Harry Compton Crick"
65+ meta = setMeta "author"
66+ (MetaInlines (watson ++ SoftBreak : crick))
67+ nullMeta
68+ in Pandoc meta mempty
69+ ]
70+
71+ , "Date" =:
72+ "#+Date: Feb. *28*, 2014" =?>
73+ let date = toList . spcSep $ [ "Feb.", strong "28" <> ",", "2014" ]
74+ meta = setMeta "date" (MetaInlines date) nullMeta
7975 in Pandoc meta mempty
8076
81− , "Multiline" =:
82− T.unlines [ "#+DESCRIPTION: /Short/ introduction"
83− , "#+DESCRIPTION: to Org-mode"
84− ] =?>
85− let description = [ Emph [Str "Short"], Space, Str "introduction", SoftBreak
86− , Str "to", Space, Str "Org-mode"
87− ]
88− meta = setMeta "description" (MetaInlines description) nullMeta
89− in Pandoc meta mempty
90− ]
77+ , testGroup "Description"
78+ [ "Single line" =:
79+ "#+DESCRIPTION: Explanatory text" =?>
80+ let description = [Str "Explanatory", Space, Str "text"]
81+ meta = setMeta "description" (MetaInlines description) nullMeta
82+ in Pandoc meta mempty
9183
92− , "Keywords" =:
93− T.unlines [ "#+KEYWORDS: pandoc, testing,"
94− , "#+KEYWORDS: Org"
95− ] =?>
96− let keywords = toList $ "pandoc, testing," <> softbreak <> "Org"
97− meta = setMeta "keywords" (MetaInlines keywords) nullMeta
98− in Pandoc meta mempty
99−
100− , "Properties drawer" =:
101− T.unlines [ " :PROPERTIES:"
102− , " :setting: foo"
103− , " :END:"
84+ , "Multiline" =:
85+ T.unlines [ "#+DESCRIPTION: /Short/ introduction"
86+ , "#+DESCRIPTION: to Org-mode"
87+ ] =?>
88+ let description = [ Emph [Str "Short"], Space, Str "introduction"
89+ , SoftBreak
90+ , Str "to", Space, Str "Org-mode"
91+ ]
92+ meta = setMeta "description" (MetaInlines description) nullMeta
93+ in Pandoc meta mempty
94+ ]
95+
96+ , "Keywords" =:
97+ T.unlines [ "#+KEYWORDS: pandoc, testing,"
98+ , "#+KEYWORDS: Org"
10499 ] =?>
105− (mempty::Blocks)
100+ let keywords = toList $ "pandoc, testing," <> softbreak <> "Org"
101+ meta = setMeta "keywords" (MetaInlines keywords) nullMeta
102+ in Pandoc meta mempty
106103
107− , "LaTeX_headers options are translated to header-includes" =:
104+ , "LaTeX_headers options are translated to header-includes" =:
108105 "#+LaTeX_header: \\usepackage{tikz}" =?>
109106 let latexInlines = rawInline "latex" "\\usepackage{tikz}"
110107 inclList = MetaList [MetaInlines (toList latexInlines)]
111108 meta = setMeta "header-includes" inclList nullMeta
112109 in Pandoc meta mempty
113110
114− , testGroup "LaTeX_CLASS"
115− [ "LaTeX_class option is translated to documentclass" =:
116− "#+LATEX_CLASS: article" =?>
117− let meta = setMeta "documentclass" (MetaString "article") nullMeta
118− in Pandoc meta mempty
111+ , testGroup "LaTeX_CLASS"
112+ [ "LaTeX_class option is translated to documentclass" =:
113+ "#+LATEX_CLASS: article" =?>
114+ let meta = setMeta "documentclass" (MetaString "article") nullMeta
115+ in Pandoc meta mempty
119116
120− , "last definition takes precedence" =:
121− T.unlines [ "#+LATEX_CLASS: this will not be used"
122− , "#+LATEX_CLASS: report"
123− ] =?>
124− let meta = setMeta "documentclass" (MetaString "report") nullMeta
125− in Pandoc meta mempty
126− ]
117+ , "last definition takes precedence" =:
118+ T.unlines [ "#+LATEX_CLASS: this will not be used"
119+ , "#+LATEX_CLASS: report"
120+ ] =?>
121+ let meta = setMeta "documentclass" (MetaString "report") nullMeta
122+ in Pandoc meta mempty
123+ ]
127124
128− , "LaTeX_class_options is translated to classoption" =:
125+ , "LaTeX_class_options is translated to classoption" =:
129126 "#+LATEX_CLASS_OPTIONS: [a4paper]" =?>
130127 let meta = setMeta "classoption" (MetaString "a4paper") nullMeta
131128 in Pandoc meta mempty
132129
133− , "LaTeX_class_options is translated to classoption" =:
130+ , "LaTeX_class_options is translated to classoption" =:
134131 "#+html_head: <meta/>" =?>
135132 let html = rawInline "html" "<meta/>"
136133 inclList = MetaList [MetaInlines (toList html)]
137134 meta = setMeta "header-includes" inclList nullMeta
138135 in Pandoc meta mempty
136+ ]
137+
138+ , "Properties drawer" =:
139+ T.unlines [ " :PROPERTIES:"
140+ , " :setting: foo"
141+ , " :END:"
142+ ] =?>
143+ (mempty::Blocks)
139144
140145 , "Logbook drawer" =:
141146 T.unlines [ " :LogBook:"