Skip to content

Commit 4139e3e

Browse files
author
Alexander Krotov
committed
Test Lua filter converting display math to inline math
1 parent 5ce91a7 commit 4139e3e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/Tests/Lua.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import Test.Tasty.QuickCheck (QuickCheckTests (..), ioProperty, testProperty)
1212
import Text.Pandoc.Arbitrary ()
1313
import Text.Pandoc.Builder (bulletList, divWith, doc, doubleQuoted, emph,
1414
header, linebreak, para, plain, rawBlock,
15-
singleQuoted, space, str, strong)
15+
singleQuoted, space, str, strong,
16+
math, displayMath)
1617
import Text.Pandoc.Class (runIOorExplode, setUserDataDir)
1718
import Text.Pandoc.Definition (Block (BlockQuote, Div, Para), Inline (Emph, Str),
1819
Attr, Meta, Pandoc, pandocTypesVersion)
@@ -48,6 +49,12 @@ tests = map (localOption (QuickCheckTests 20))
4849
(doc $ bulletList [plain (str "alfa"), plain (str "bravo")])
4950
(doc $ bulletList [para (str "alfa"), para (str "bravo")])
5051

52+
, testCase "convert display math to inline math" $
53+
assertFilterConversion "display math becomes inline math"
54+
"math.lua"
55+
(doc $ para (displayMath "5+5"))
56+
(doc $ para (math "5+5"))
57+
5158
, testCase "make hello world document" $
5259
assertFilterConversion "Document contains 'Hello, World!'"
5360
"hello-world-doc.lua"

test/lua/math.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
return {
2+
{
3+
Math = function (elem)
4+
if elem.mathtype == "DisplayMath" then
5+
elem.mathtype = "InlineMath"
6+
end
7+
return elem
8+
end,
9+
}
10+
}

0 commit comments

Comments
 (0)