aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOCzarnecki <44535552+OCzarnecki@users.noreply.github.com>2021-08-16 06:57:57 +0200
committerGitHub <noreply@github.com>2021-08-15 21:57:57 -0700
commite37cf4484d38c171d9f7477a8ae9eca9643cc426 (patch)
tree62984d5cf0e54867f80ef8fcbc646ff598e9a094 /test
parent72447a563c415a3d8addc7a2b2edd93f9fe56ebe (diff)
downloadpandoc-e37cf4484d38c171d9f7477a8ae9eca9643cc426.tar.gz
Multimarkdown sub- and superscripts (#5512) (#7188)
Added an extension `short_subsuperscripts` which modifies the behavior of `subscript` and `superscript`, allowing subscripts or superscripts containing only alphanumerics to end with a space character (eg. `x^2 = 4` or `H~2 is combustible`). This improves support for multimarkdown. Closes #5512. Add `Ext_short_subsuperscripts` constructor to `Extension` [API change]. This is enabled by default for `markdown_mmd`.
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Readers/Markdown.hs48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs
index f055ab197..02fc0d8ce 100644
--- a/test/Tests/Readers/Markdown.hs
+++ b/test/Tests/Readers/Markdown.hs
@@ -36,6 +36,9 @@ markdownGH :: Text -> Pandoc
markdownGH = purely $ readMarkdown def {
readerExtensions = githubMarkdownExtensions }
+markdownMMD :: Text -> Pandoc
+markdownMMD = purely $ readMarkdown def {
+ readerExtensions = multimarkdownExtensions }
infix 4 =:
(=:) :: ToString c
=> String -> (Text, c) -> TestTree
@@ -360,6 +363,51 @@ tests = [ testGroup "inline code"
("**this should \"be bold**"
=?> para (strong "this should \8220be bold"))
]
+ , testGroup "sub- and superscripts"
+ [
+ test markdownMMD "normal subscript"
+ ("H~2~"
+ =?> para ("H" <> subscript "2"))
+ , test markdownMMD "normal superscript"
+ ("x^3^"
+ =?> para ("x" <> superscript "3"))
+ , test markdownMMD "short subscript delimeted by space"
+ ("O~2 is dangerous"
+ =?> para ("O" <> subscript "2" <> space <> "is dangerous"))
+ , test markdownMMD "short subscript delimeted by newline"
+ ("O~2\n"
+ =?> para ("O" <> subscript "2"))
+ , test markdownMMD "short subscript delimeted by EOF"
+ ("O~2"
+ =?> para ("O" <> subscript "2"))
+ , test markdownMMD "short subscript delimited by punctuation"
+ ("O~2."
+ =?> para ("O" <> subscript "2" <> "."))
+ , test markdownMMD "short subscript delimited by emph"
+ ("O~2*combustible!*"
+ =?> para ("O" <> subscript "2" <> emph "combustible!"))
+ , test markdownMMD "no nesting in short subscripts"
+ ("y~*2*"
+ =?> para ("y~" <> emph "2"))
+ , test markdownMMD "short superscript delimeted by space"
+ ("x^2 = y"
+ =?> para ("x" <> superscript "2" <> space <> "= y"))
+ , test markdownMMD "short superscript delimeted by newline"
+ ("x^2\n"
+ =?> para ("x" <> superscript "2"))
+ , test markdownMMD "short superscript delimeted by ExF"
+ ("x^2"
+ =?> para ("x" <> superscript "2"))
+ , test markdownMMD "short superscript delimited by punctuation"
+ ("x^2."
+ =?> para ("x" <> superscript "2" <> "."))
+ , test markdownMMD "short superscript delimited by emph"
+ ("x^2*combustible!*"
+ =?> para ("x" <> superscript "2" <> emph "combustible!"))
+ , test markdownMMD "no nesting in short superscripts"
+ ("y^*2*"
+ =?> para ("y^" <> emph "2"))
+ ]
, testGroup "footnotes"
[ "indent followed by newline and flush-left text" =:
"[^1]\n\n[^1]: my note\n\n \nnot in note\n"