diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
index ae068a94f..95ea0c643 100644
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -16,6 +16,7 @@ into InDesign with File -> Place.
module Text.Pandoc.Writers.ICML (writeICML) where
import Text.Pandoc.Definition
import Text.Pandoc.XML
+import Text.Pandoc.Readers.TeXMath (texMathToInlines)
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Shared (splitBy)
import Text.Pandoc.Options
@@ -410,7 +411,8 @@ inlineToICML opts style (Cite _ lst) = inlinesToICML opts style lst
inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str
inlineToICML _ style Space = charStyle style space
inlineToICML _ style LineBreak = charStyle style $ text lineSeparator
-inlineToICML _ style (Math _ str) = charStyle style $ text $ escapeStringForXML str --InDesign doesn't really do math
+inlineToICML opts style (Math mt str) =
+ cat <$> mapM (inlineToICML opts style) (texMathToInlines mt str)
inlineToICML _ _ (RawInline f str)
| f == Format "icml" = return $ text str
| otherwise = return empty
diff --git a/tests/writer.icml b/tests/writer.icml
index b6f5b5e32..cd71fa86b 100644
--- a/tests/writer.icml
+++ b/tests/writer.icml
@@ -1864,17 +1864,49 @@ These should not be escaped: \$ \\ \> \[ \{
- 2+2=4
+ 2
+
+
+
+ +
+
+
+
+ 2
+
+
+
+ =
+
+
+
+ 4
-
- x \in y
+
+ x
+
+
+
+ ∈
+
+
+
+ y
-
- \alpha \wedge \omega
+
+ α
+
+
+
+ ∧
+
+
+
+ ω
@@ -1883,7 +1915,7 @@ These should not be escaped: \$ \\ \> \[ \{
-
+
p
@@ -1895,15 +1927,33 @@ These should not be escaped: \$ \\ \> \[ \{
Here’s some display math:
- \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
Here’s one that has a line break in it:
-
- \alpha + \omega \times x^2
+
+ α
+
+
+
+ +
+
+
+
+ ω
+
+
+
+ ×
+
+
+
+ x
+
+ 2
.