git.iko.soy/typeable/pandoc
on master help sign in
Moved escape and nullBlock parsers from ParserCombinators/Pandoc

to Pandoc/Shared. Reason: ParserCombinators/Pandoc is for general-purpose parsers that don't require Pandoc.Definition. Also removed some unnecessary imports from Pandoc/Shared. git-svn-id: https://pandoc.googlecode.com/svn/trunk@584 788f1e2b-df1e-0410-8736-df70ead52e1b

commite15fd3bf86f91d6c14bf9ba2e2aa7057dc51d72b authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 15 Apr 2007, 16:20 (20 years ago) parent24ee5f1
2 files changed+18−19
src/Text/Pandoc/Shared.hs+18−3 src/Text/ParserCombinators/Pandoc.hs−16
src/Text/Pandoc/Shared.hs+18−3
@@ -54,6 +54,8 @@ module Text.Pandoc.Shared (
5454 QuoteContext (..),
5555 ParserState (..),
5656 defaultParserState,
57+ nullBlock,
58+ escaped,
5759 -- * Native format prettyprinting
5860 prettyPandoc,
5961 -- * Pandoc block list processing
@@ -68,10 +70,8 @@ module Text.Pandoc.Shared (
6870 refsMatch,
6971 ) where
7072import Text.Pandoc.Definition
71−import Text.ParserCombinators.Parsec as Parsec
73+import Text.ParserCombinators.Parsec
7274import Text.Pandoc.Entities ( decodeEntities, escapeStringForXML )
73−import Text.PrettyPrint.HughesPJ as PP ( text, char, (<>),
74− ($$), nest, Doc, isEmpty )
7575import Data.Char ( toLower, ord )
7676import Data.List ( find, groupBy, isPrefixOf )
7777
@@ -172,6 +172,21 @@ defaultParserState =
172172 stateColumns = 80,
173173 stateHeaderTable = [] }
174174
175+-- | Parses a character and returns 'Null' (so that the parser can move on
176+-- if it gets stuck).
177+nullBlock :: GenParser Char st Block
178+nullBlock = do
179+ anyChar
180+ return Null
181+
182+-- | Parses backslash, then applies character parser.
183+escaped :: GenParser Char st Char -- ^ Parser for character to escape
184+ -> GenParser Char st Inline
185+escaped parser = try (do
186+ char '\\'
187+ result <- parser
188+ return (Str [result]))
189+
175190-- | Indent string as a block.
176191indentBy :: Int -- ^ Number of spaces to indent the block
177192 -> Int -- ^ Number of spaces (rel to block) to indent first line
src/Text/ParserCombinators/Pandoc.hs−16
@@ -44,7 +44,6 @@ module Text.ParserCombinators.Pandoc (
4444 lineClump
4545 ) where
4646import Text.ParserCombinators.Parsec
47−import Text.Pandoc.Definition
4847import Text.Pandoc.Shared
4948import Data.Char ( toUpper, toLower )
5049
@@ -52,13 +51,6 @@ import Data.Char ( toUpper, toLower )
5251anyLine :: GenParser Char st [Char]
5352anyLine = manyTill anyChar (newline <|> (do{eof; return '\n'}))
5453
55−-- | Parses a character and returns 'Null' (so that the parser can move on
56−-- if it gets stuck).
57−nullBlock :: GenParser Char st Block
58−nullBlock = do
59− anyChar
60− return Null
61−
6254-- | Parses a space or tab.
6355spaceChar :: CharParser st Char
6456spaceChar = oneOf " \t"
@@ -77,14 +69,6 @@ blankline = try (do
7769blanklines :: GenParser Char st [Char]
7870blanklines = try (many1 blankline)
7971
80−-- | Parses backslash, then applies character parser.
81−escaped :: GenParser Char st Char -- ^ Parser for character to escape
82− -> GenParser Char st Inline
83−escaped parser = try (do
84− char '\\'
85− result <- parser
86− return (Str [result]))
87−
8872-- | Parses material enclosed between start and end parsers.
8973enclosed :: GenParser Char st t -- ^ start parser
9074 -> GenParser Char st end -- ^ end parser