git.iko.soy/typeable/pandoc
on master help sign in
Added Text.Pandoc.Readers.LaTeX.Types (new exported module).

Exports Macro, Tok, TokType, Line, Column. API change.

commitaf899f515c0dc468a7a88bfe1a030e622ebc4109 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 5 Jul 2017, 15:39 (9 years ago) parent0c100a2
3 files changed+52−11
pandoc.cabal+1 src/Text/Pandoc/Readers/LaTeX.hs+3−11 src/Text/Pandoc/Readers/LaTeX/Types.hs+48
pandoc.cabal+1
@@ -366,6 +366,7 @@ Library
366366 Text.Pandoc.Readers,
367367 Text.Pandoc.Readers.HTML,
368368 Text.Pandoc.Readers.LaTeX,
369+ Text.Pandoc.Readers.LaTeX.Types,
369370 Text.Pandoc.Readers.Markdown,
370371 Text.Pandoc.Readers.CommonMark,
371372 Text.Pandoc.Readers.MediaWiki,
src/Text/Pandoc/Readers/LaTeX.hs+3−11
@@ -38,7 +38,7 @@ TODO:
3838module Text.Pandoc.Readers.LaTeX ( readLaTeX,
3939 rawLaTeXInline,
4040 rawLaTeXBlock,
41− inlineCommand,
41+ inlineCommand
4242 ) where
4343
4444import Control.Applicative (many, optional, (<|>))
@@ -66,6 +66,8 @@ import Text.Pandoc.Parsing hiding (many, optional, withRaw,
6666 mathInline, mathDisplay, macro,
6767 space, (<|>), spaces, blankline)
6868import Text.Pandoc.Shared
69+import Text.Pandoc.Readers.LaTeX.Types (Macro(..), Tok(..),
70+ TokType(..), Line, Column)
6971import Text.Pandoc.Walk
7072import Text.Pandoc.Error (PandocError(PandocParsecError, PandocMacroLoop))
7173
@@ -113,9 +115,6 @@ testParser p t = do
113115 Left e -> error (show e)
114116 Right r -> return r
115117
116−data Macro = Macro Int (Maybe [Tok]) [Tok]
117− deriving Show
118−
119118data LaTeXState = LaTeXState{ sOptions :: ReaderOptions
120119 , sMeta :: Meta
121120 , sQuoteContext :: QuoteContext
@@ -228,13 +227,6 @@ rawLaTeXInline = mzero
228227inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
229228inlineCommand = mzero
230229
231−data TokType = CtrlSeq Text | Spaces | Newline | Symbol | Word | Comment |
232− Esc1 | Esc2 | Arg Int
233− deriving (Eq, Ord, Show)
234−
235−data Tok = Tok (Line, Column) TokType Text
236− deriving (Eq, Ord, Show)
237−
238230tokenize :: Text -> [Tok]
239231tokenize = totoks (1, 1)
240232
src/Text/Pandoc/Readers/LaTeX/Types.hsnew file+48
@@ -0,0 +1,48 @@
1+{-
2+Copyright (C) 2017 John MacFarlane <jgm@berkeley.edu>
3+
4+This program is free software; you can redistribute it and/or modify
5+it under the terms of the GNU General Public License as published by
6+the Free Software Foundation; either version 2 of the License, or
7+(at your option) any later version.
8+
9+This program is distributed in the hope that it will be useful,
10+but WITHOUT ANY WARRANTY; without even the implied warranty of
11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+GNU General Public License for more details.
13+
14+You should have received a copy of the GNU General Public License
15+along with this program; if not, write to the Free Software
16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+-}
18+
19+{- |
20+ Module : Text.Pandoc.Readers.LaTeX.Types
21+ Copyright : Copyright (C) 2017 John MacFarlane
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
25+ Stability : alpha
26+ Portability : portable
27+
28+Types for LaTeX tokens and macros.
29+-}
30+module Text.Pandoc.Readers.LaTeX.Types ( Tok(..)
31+ , TokType(..)
32+ , Macro(..)
33+ , Line
34+ , Column )
35+where
36+import Data.Text (Text)
37+import Text.Parsec.Pos (Line, Column)
38+
39+data TokType = CtrlSeq Text | Spaces | Newline | Symbol | Word | Comment |
40+ Esc1 | Esc2 | Arg Int
41+ deriving (Eq, Ord, Show)
42+
43+data Tok = Tok (Line, Column) TokType Text
44+ deriving (Eq, Ord, Show)
45+
46+data Macro = Macro Int (Maybe [Tok]) [Tok]
47+ deriving Show
48+