2017-12-24 22:48:18 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2019-02-04 22:52:31 +01:00
|
|
|
{- |
|
|
|
|
Module : Tests.Readers.Org.Block.Figure
|
2022-01-01 20:02:31 +01:00
|
|
|
Copyright : © 2014-2022 Albert Krewinkel
|
2019-02-04 22:52:31 +01:00
|
|
|
License : GNU GPL, version 2 or above
|
|
|
|
|
|
|
|
Maintainer : Albert Krewinkel <albert@zeitkraut.de>
|
|
|
|
Stability : alpha
|
|
|
|
Portability : portable
|
|
|
|
|
|
|
|
Test parsing of org figures.
|
|
|
|
-}
|
2017-12-24 22:48:18 +01:00
|
|
|
module Tests.Readers.Org.Block.Figure (tests) where
|
|
|
|
|
|
|
|
import Test.Tasty (TestTree)
|
|
|
|
import Tests.Helpers ((=?>))
|
|
|
|
import Tests.Readers.Org.Shared ((=:))
|
|
|
|
import Text.Pandoc.Builder (image, imageWith, para)
|
|
|
|
import qualified Data.Text as T
|
|
|
|
|
|
|
|
tests :: [TestTree]
|
|
|
|
tests =
|
|
|
|
[ "Figure" =:
|
|
|
|
T.unlines [ "#+caption: A very courageous man."
|
|
|
|
, "#+name: goodguy"
|
|
|
|
, "[[file:edward.jpg]]"
|
|
|
|
] =?>
|
|
|
|
para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
|
|
|
|
|
|
|
|
, "Figure with no name" =:
|
|
|
|
T.unlines [ "#+caption: I've been through the desert on this"
|
|
|
|
, "[[file:horse.png]]"
|
|
|
|
] =?>
|
|
|
|
para (image "horse.png" "fig:" "I've been through the desert on this")
|
|
|
|
|
|
|
|
, "Figure with `fig:` prefix in name" =:
|
|
|
|
T.unlines [ "#+caption: Used as a metapher in evolutionary biology."
|
|
|
|
, "#+name: fig:redqueen"
|
|
|
|
, "[[./the-red-queen.jpg]]"
|
|
|
|
] =?>
|
|
|
|
para (image "./the-red-queen.jpg" "fig:redqueen"
|
|
|
|
"Used as a metapher in evolutionary biology.")
|
|
|
|
|
|
|
|
, "Figure with HTML attributes" =:
|
2020-11-18 02:06:30 +08:00
|
|
|
T.unlines [ "#+caption: mah brain just explodid"
|
|
|
|
, "#+name: lambdacat"
|
|
|
|
, "#+attr_html: :style color: blue :role button"
|
2017-12-24 22:48:18 +01:00
|
|
|
, "[[file:lambdacat.jpg]]"
|
|
|
|
] =?>
|
|
|
|
let kv = [("style", "color: blue"), ("role", "button")]
|
|
|
|
name = "fig:lambdacat"
|
|
|
|
caption = "mah brain just explodid"
|
|
|
|
in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption)
|
|
|
|
|
2019-07-21 23:06:17 +02:00
|
|
|
, "LaTeX attributes are ignored" =:
|
2020-11-18 02:06:30 +08:00
|
|
|
T.unlines [ "#+caption: Attribute after caption"
|
|
|
|
, "#+attr_latex: :float nil"
|
2019-07-21 23:06:17 +02:00
|
|
|
, "[[file:test.png]]"
|
|
|
|
] =?>
|
|
|
|
para (image "test.png" "fig:" "Attribute after caption")
|
|
|
|
|
2017-12-24 22:48:18 +01:00
|
|
|
, "Labelled figure" =:
|
2020-11-18 02:06:30 +08:00
|
|
|
T.unlines [ "#+caption: My figure"
|
|
|
|
, "#+label: fig:myfig"
|
2017-12-24 22:48:18 +01:00
|
|
|
, "[[file:blub.png]]"
|
|
|
|
] =?>
|
|
|
|
let attr = ("fig:myfig", mempty, mempty)
|
|
|
|
in para (imageWith attr "blub.png" "fig:" "My figure")
|
|
|
|
|
|
|
|
, "Figure with empty caption" =:
|
2020-11-18 02:06:30 +08:00
|
|
|
T.unlines [ "#+caption:"
|
2017-12-24 22:48:18 +01:00
|
|
|
, "[[file:guess.jpg]]"
|
|
|
|
] =?>
|
|
|
|
para (image "guess.jpg" "fig:" "")
|
|
|
|
]
|