aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/LaTeX/Types.hs
blob: c06b7e9230829c8ee17b033832a04ed2326a4a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module Text.Pandoc.Writers.LaTeX.Types
  ( LW
  , WriterState (..)
  , startingState
  ) where

import Control.Monad.State.Strict (StateT)
import Data.Text (Text)
import Text.DocLayout (Doc)
import Text.Pandoc.Options
  ( WriterOptions (writerIncremental, writerTopLevelDivision)
  , TopLevelDivision (..)
  )

-- | LaTeX writer type. The type constructor @m@ will typically be an
-- instance of PandocMonad.
type LW m = StateT WriterState m

data WriterState =
  WriterState
  { stInNote        :: Bool          -- ^ true if we're in a note
  , stInQuote       :: Bool          -- ^ true if in a blockquote
  , stExternalNotes :: Bool          -- ^ true if in context where
                                     --   we need to store footnotes
  , stInMinipage    :: Bool          -- ^ true if in minipage
  , stInHeading     :: Bool          -- ^ true if in a section heading
  , stInItem        :: Bool          -- ^ true if in \item[..]
  , stNotes         :: [Doc Text]    -- ^ notes in a minipage
  , stOLLevel       :: Int           -- ^ level of ordered list nesting
  , stOptions       :: WriterOptions -- ^ writer options, so they don't have to
                                     --   be parameter
  , stVerbInNote    :: Bool          -- ^ true if document has verbatim text in note
  , stTable         :: Bool          -- ^ true if document has a table
  , stMultiRow      :: Bool          -- ^ true if document has multirow cells
  , stStrikeout     :: Bool          -- ^ true if document has strikeout
  , stUrl           :: Bool          -- ^ true if document has visible URL link
  , stGraphics      :: Bool          -- ^ true if document contains images
  , stLHS           :: Bool          -- ^ true if document has literate haskell code
  , stHasChapters   :: Bool          -- ^ true if document has chapters
  , stCsquotes      :: Bool          -- ^ true if document uses csquotes
  , stHighlighting  :: Bool          -- ^ true if document has highlighted code
  , stIncremental   :: Bool          -- ^ true if beamer lists should be
  , stZwnj          :: Bool          -- ^ true if document has a ZWNJ character
  , stInternalLinks :: [Text]        -- ^ list of internal link targets
  , stBeamer        :: Bool          -- ^ produce beamer
  , stEmptyLine     :: Bool          -- ^ true if no content on line
  , stHasCslRefs    :: Bool          -- ^ has a Div with class refs
  , stIsFirstInDefinition :: Bool    -- ^ first block in a defn list
  }

startingState :: WriterOptions -> WriterState
startingState options =
  WriterState
  { stInNote = False
  , stInQuote = False
  , stExternalNotes = False
  , stInHeading = False
  , stInMinipage = False
  , stInItem = False
  , stNotes = []
  , stOLLevel = 1
  , stOptions = options
  , stVerbInNote = False
  , stTable = False
  , stMultiRow = False
  , stStrikeout = False
  , stUrl = False
  , stGraphics = False
  , stLHS = False
  , stHasChapters = case writerTopLevelDivision options of
                      TopLevelPart    -> True
                      TopLevelChapter -> True
                      _               -> False
  , stCsquotes = False
  , stHighlighting = False
  , stIncremental = writerIncremental options
  , stZwnj = False
  , stInternalLinks = []
  , stBeamer = False
  , stEmptyLine = True
  , stHasCslRefs = False
  , stIsFirstInDefinition = False
  }