@@ -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