24f68654e9
If we're producing a fragment, just skip normalization. After all, the fragment might be somewhere in the middle of the document. It's more important for fragments to have consistency in rendering (so they can be pieced together) than to normalize. This closes #2394. It's simpler and more robust than my earlier fix.
109 lines
3.4 KiB
Haskell
109 lines
3.4 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
module Tests.Writers.RST (tests) where
|
|
|
|
import Test.Framework
|
|
import Text.Pandoc.Builder
|
|
import Text.Pandoc
|
|
import Tests.Helpers
|
|
import Tests.Arbitrary()
|
|
|
|
infix 4 =:
|
|
(=:) :: (ToString a, ToPandoc a)
|
|
=> String -> (a, String) -> Test
|
|
(=:) = test (writeRST def{ writerHighlight = True } . toPandoc)
|
|
|
|
tests :: [Test]
|
|
tests = [ testGroup "rubrics"
|
|
[ "in list item" =:
|
|
bulletList [header 2 (text "foo")] =?>
|
|
"- .. rubric:: foo"
|
|
, "in definition list item" =:
|
|
definitionList [(text "foo", [header 2 (text "bar"),
|
|
para $ text "baz"])] =?>
|
|
unlines
|
|
[ "foo"
|
|
, " .. rubric:: bar"
|
|
, ""
|
|
, " baz"]
|
|
, "in block quote" =:
|
|
blockQuote (header 1 (text "bar")) =?>
|
|
" .. rubric:: bar"
|
|
, "with id" =:
|
|
blockQuote (headerWith ("foo",[],[]) 1 (text "bar")) =?>
|
|
unlines
|
|
[ " .. rubric:: bar"
|
|
, " :name: foo"]
|
|
, "with id class" =:
|
|
blockQuote (headerWith ("foo",["baz"],[]) 1 (text "bar")) =?>
|
|
unlines
|
|
[ " .. rubric:: bar"
|
|
, " :name: foo"
|
|
, " :class: baz"]
|
|
]
|
|
, testGroup "headings"
|
|
[ "normal heading" =:
|
|
header 1 (text "foo") =?>
|
|
unlines
|
|
[ "foo"
|
|
, "==="]
|
|
-- note: heading normalization is only done in standalone mode
|
|
, test (writeRST def{ writerStandalone = True,
|
|
writerTemplate = "$body$\n" } . toPandoc)
|
|
"heading levels" $
|
|
header 1 (text "Header 1") <>
|
|
header 3 (text "Header 2") <>
|
|
header 2 (text "Header 2") <>
|
|
header 1 (text "Header 1") <>
|
|
header 4 (text "Header 2") <>
|
|
header 5 (text "Header 3") <>
|
|
header 3 (text "Header 2") =?>
|
|
unlines
|
|
[ "Header 1"
|
|
, "========"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"
|
|
, ""
|
|
, "Header 1"
|
|
, "========"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"
|
|
, ""
|
|
, "Header 3"
|
|
, "~~~~~~~~"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"]
|
|
, test (writeRST def{ writerStandalone = True,
|
|
writerTemplate = "$body$\n" } . toPandoc)
|
|
"minimal heading levels" $
|
|
header 2 (text "Header 1") <>
|
|
header 3 (text "Header 2") <>
|
|
header 2 (text "Header 1") <>
|
|
header 4 (text "Header 2") <>
|
|
header 5 (text "Header 3") <>
|
|
header 3 (text "Header 2") =?>
|
|
unlines
|
|
[ "Header 1"
|
|
, "========"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"
|
|
, ""
|
|
, "Header 1"
|
|
, "========"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"
|
|
, ""
|
|
, "Header 3"
|
|
, "~~~~~~~~"
|
|
, ""
|
|
, "Header 2"
|
|
, "--------"]
|
|
]
|
|
]
|