aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.cabal1
-rw-r--r--src/Text/Pandoc/Writers/Ms.hs4
-rw-r--r--test/Tests/Writers/Ms.hs37
-rw-r--r--test/test-pandoc.hs2
4 files changed, 43 insertions, 1 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index a36f3942c..83c7f1805 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -816,6 +816,7 @@ test-suite test-pandoc
Tests.Writers.FB2
Tests.Writers.Powerpoint
Tests.Writers.OOXML
+ Tests.Writers.Ms
if os(windows)
cpp-options: -D_WINDOWS
default-language: Haskell2010
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index d38b874d4..561053c88 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -204,7 +204,9 @@ blockToMs opts (CodeBlock attr str) = do
literal ".IP" $$
literal ".nf" $$
literal "\\f[C]" $$
- hlCode $$
+ ((case T.uncons str of
+ Just ('.',_) -> literal "\\&"
+ _ -> mempty) <> hlCode) $$
literal "\\f[]" $$
literal ".fi"
blockToMs opts (LineBlock ls) = do
diff --git a/test/Tests/Writers/Ms.hs b/test/Tests/Writers/Ms.hs
new file mode 100644
index 000000000..d73603314
--- /dev/null
+++ b/test/Tests/Writers/Ms.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Ms (tests) where
+
+import Prelude
+import Test.Tasty
+import Tests.Helpers
+import Text.Pandoc
+import Text.Pandoc.Builder
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> TestTree
+(=:) = test (purely (writeMs def . toPandoc))
+
+tests :: [TestTree]
+tests = [ testGroup "code blocks"
+ [ "basic"
+ =: codeBlock "hello"
+ =?> unlines
+ [ ".IP"
+ , ".nf"
+ , "\\f[C]"
+ , "hello"
+ , "\\f[]"
+ , ".fi"]
+ , "escape starting ."
+ =: codeBlock ". hello"
+ =?> unlines
+ [ ".IP"
+ , ".nf"
+ , "\\f[C]"
+ , "\\&. hello"
+ , "\\f[]"
+ , ".fi"]
+ ]
+ ]
diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs
index ff7661094..d0a1a6f18 100644
--- a/test/test-pandoc.hs
+++ b/test/test-pandoc.hs
@@ -37,6 +37,7 @@ import qualified Tests.Writers.JATS
import qualified Tests.Writers.Jira
import qualified Tests.Writers.LaTeX
import qualified Tests.Writers.Markdown
+import qualified Tests.Writers.Ms
import qualified Tests.Writers.Muse
import qualified Tests.Writers.Native
import qualified Tests.Writers.Org
@@ -70,6 +71,7 @@ tests pandocPath = testGroup "pandoc tests"
, testGroup "Muse" Tests.Writers.Muse.tests
, testGroup "FB2" Tests.Writers.FB2.tests
, testGroup "PowerPoint" Tests.Writers.Powerpoint.tests
+ , testGroup "Ms" Tests.Writers.Ms.tests
]
, testGroup "Readers"
[ testGroup "LaTeX" Tests.Readers.LaTeX.tests