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
This commit is contained in:
fiddlosopher
2007-04-15 16:20:07 +00:00
parent 24ee5f1f49
commit e15fd3bf86
2 changed files with 18 additions and 19 deletions
+18 -3
View File
@@ -54,6 +54,8 @@ module Text.Pandoc.Shared (
QuoteContext (..),
ParserState (..),
defaultParserState,
nullBlock,
escaped,
-- * Native format prettyprinting
prettyPandoc,
-- * Pandoc block list processing
@@ -68,10 +70,8 @@ module Text.Pandoc.Shared (
refsMatch,
) where
import Text.Pandoc.Definition
import Text.ParserCombinators.Parsec as Parsec
import Text.ParserCombinators.Parsec
import Text.Pandoc.Entities ( decodeEntities, escapeStringForXML )
import Text.PrettyPrint.HughesPJ as PP ( text, char, (<>),
($$), nest, Doc, isEmpty )
import Data.Char ( toLower, ord )
import Data.List ( find, groupBy, isPrefixOf )
@@ -172,6 +172,21 @@ defaultParserState =
stateColumns = 80,
stateHeaderTable = [] }
-- | Parses a character and returns 'Null' (so that the parser can move on
-- if it gets stuck).
nullBlock :: GenParser Char st Block
nullBlock = do
anyChar
return Null
-- | Parses backslash, then applies character parser.
escaped :: GenParser Char st Char -- ^ Parser for character to escape
-> GenParser Char st Inline
escaped parser = try (do
char '\\'
result <- parser
return (Str [result]))
-- | Indent string as a block.
indentBy :: Int -- ^ Number of spaces to indent the block
-> Int -- ^ Number of spaces (rel to block) to indent first line
-16
View File
@@ -44,7 +44,6 @@ module Text.ParserCombinators.Pandoc (
lineClump
) where
import Text.ParserCombinators.Parsec
import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Data.Char ( toUpper, toLower )
@@ -52,13 +51,6 @@ import Data.Char ( toUpper, toLower )
anyLine :: GenParser Char st [Char]
anyLine = manyTill anyChar (newline <|> (do{eof; return '\n'}))
-- | Parses a character and returns 'Null' (so that the parser can move on
-- if it gets stuck).
nullBlock :: GenParser Char st Block
nullBlock = do
anyChar
return Null
-- | Parses a space or tab.
spaceChar :: CharParser st Char
spaceChar = oneOf " \t"
@@ -77,14 +69,6 @@ blankline = try (do
blanklines :: GenParser Char st [Char]
blanklines = try (many1 blankline)
-- | Parses backslash, then applies character parser.
escaped :: GenParser Char st Char -- ^ Parser for character to escape
-> GenParser Char st Inline
escaped parser = try (do
char '\\'
result <- parser
return (Str [result]))
-- | Parses material enclosed between start and end parsers.
enclosed :: GenParser Char st t -- ^ start parser
-> GenParser Char st end -- ^ end parser