Blame test/Tests/Readers/Org/Block/Figure.hs

Packit Service d2f85f
{-# LANGUAGE OverloadedStrings #-}
Packit Service d2f85f
module Tests.Readers.Org.Block.Figure (tests) where
Packit Service d2f85f
Packit Service d2f85f
import Test.Tasty (TestTree)
Packit Service d2f85f
import Tests.Helpers ((=?>))
Packit Service d2f85f
import Tests.Readers.Org.Shared ((=:))
Packit Service d2f85f
import Text.Pandoc.Builder (image, imageWith, para)
Packit Service d2f85f
import qualified Data.Text as T
Packit Service d2f85f
Packit Service d2f85f
tests :: [TestTree]
Packit Service d2f85f
tests =
Packit Service d2f85f
  [ "Figure" =:
Packit Service d2f85f
      T.unlines [ "#+caption: A very courageous man."
Packit Service d2f85f
                , "#+name: goodguy"
Packit Service d2f85f
                , "[[file:edward.jpg]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
Packit Service d2f85f
Packit Service d2f85f
  , "Figure with no name" =:
Packit Service d2f85f
      T.unlines [ "#+caption: I've been through the desert on this"
Packit Service d2f85f
                , "[[file:horse.png]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      para (image "horse.png" "fig:" "I've been through the desert on this")
Packit Service d2f85f
Packit Service d2f85f
  , "Figure with `fig:` prefix in name" =:
Packit Service d2f85f
      T.unlines [ "#+caption: Used as a metapher in evolutionary biology."
Packit Service d2f85f
                , "#+name: fig:redqueen"
Packit Service d2f85f
                , "[[./the-red-queen.jpg]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      para (image "./the-red-queen.jpg" "fig:redqueen"
Packit Service d2f85f
                  "Used as a metapher in evolutionary biology.")
Packit Service d2f85f
Packit Service d2f85f
  , "Figure with HTML attributes" =:
Packit Service d2f85f
      T.unlines [ "#+CAPTION: mah brain just explodid"
Packit Service d2f85f
                , "#+NAME: lambdacat"
Packit Service d2f85f
                , "#+ATTR_HTML: :style color: blue :role button"
Packit Service d2f85f
                , "[[file:lambdacat.jpg]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      let kv = [("style", "color: blue"), ("role", "button")]
Packit Service d2f85f
          name = "fig:lambdacat"
Packit Service d2f85f
          caption = "mah brain just explodid"
Packit Service d2f85f
      in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption)
Packit Service d2f85f
Packit Service d2f85f
  , "Labelled figure" =:
Packit Service d2f85f
      T.unlines [ "#+CAPTION: My figure"
Packit Service d2f85f
                , "#+LABEL: fig:myfig"
Packit Service d2f85f
                , "[[file:blub.png]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      let attr = ("fig:myfig", mempty, mempty)
Packit Service d2f85f
      in para (imageWith attr "blub.png" "fig:" "My figure")
Packit Service d2f85f
Packit Service d2f85f
  , "Figure with empty caption" =:
Packit Service d2f85f
      T.unlines [ "#+CAPTION:"
Packit Service d2f85f
                , "[[file:guess.jpg]]"
Packit Service d2f85f
                ] =?>
Packit Service d2f85f
      para (image "guess.jpg" "fig:" "")
Packit Service d2f85f
  ]