diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-04-15 16:20:07 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-04-15 16:20:07 +0000 |
commit | e15fd3bf86f91d6c14bf9ba2e2aa7057dc51d72b (patch) | |
tree | 08cd363c8fbb83cb85bd79d67d93866b2916fcfe /src/Text/Pandoc | |
parent | 24ee5f1f49ebb7e0cf54640a21518af084b7d06d (diff) | |
download | pandoc-e15fd3bf86f91d6c14bf9ba2e2aa7057dc51d72b.tar.gz |
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
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index e231163eb..00060f9e9 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -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 |