aboutsummaryrefslogtreecommitdiff
path: root/src/Text/ParserCombinators/Pandoc.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-15 19:52:42 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-15 19:52:42 +0000
commit60989d0637780787fb337b94af212f1ee9e1ae22 (patch)
tree95b5caa1e7e304a47739532a9c4d3767ce54435c /src/Text/ParserCombinators/Pandoc.hs
parent4224d913880e4f77a358cda868c9d1ca75820506 (diff)
downloadpandoc-60989d0637780787fb337b94af212f1ee9e1ae22.tar.gz
Added support for tables in markdown reader and in LaTeX,
DocBook, and HTML writers. The syntax is documented in README. Tests have been added to the test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@493 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/ParserCombinators/Pandoc.hs')
-rw-r--r--src/Text/ParserCombinators/Pandoc.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Text/ParserCombinators/Pandoc.hs b/src/Text/ParserCombinators/Pandoc.hs
index b55ceb23d..a825ef8ff 100644
--- a/src/Text/ParserCombinators/Pandoc.hs
+++ b/src/Text/ParserCombinators/Pandoc.hs
@@ -41,7 +41,8 @@ module Text.ParserCombinators.Pandoc (
enclosed,
blankBlock,
nullBlock,
- stringAnyCase
+ stringAnyCase,
+ parseFromStr
) where
import Text.ParserCombinators.Parsec
import Text.Pandoc.Definition
@@ -138,3 +139,14 @@ stringAnyCase (x:xs) = try (do
firstChar <- choice [ char (toUpper x), char (toLower x) ]
rest <- stringAnyCase xs
return (firstChar:rest))
+
+-- | Parse contents of 'str' using 'parser' and return result.
+parseFromStr :: GenParser tok st a -> [tok] -> GenParser tok st a
+parseFromStr parser str = try $ do
+ oldInput <- getInput
+ setInput str
+ result <- parser
+ setInput oldInput
+ return result
+
+