pandoc/test/Tests/Writers/Ms.hs
Michael Hoffmann 09ea10e2b1 Escape starting periods in ms writer code blocks
If a line of ms code block output starts with a period (.), it should
be prepended by '\&' so that it is not interpreted as a roff command.

Fixes #6505
2020-07-08 23:52:28 +02:00

37 lines
880 B
Haskell

{-# 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"]
]
]