From d6a9ba1cdc4cb10d34c61593d04868da3abb5e40 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 6 May 2014 22:28:11 -0700 Subject: Make `--trace` work with textile reader. --- src/Text/Pandoc/Readers/Textile.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 3c07a4d85..b67e8fbc8 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -61,9 +61,11 @@ import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..)) import Text.HTML.TagSoup.Match import Data.List ( intercalate ) import Data.Char ( digitToInt, isUpper) -import Control.Monad ( guard, liftM ) +import Control.Monad ( guard, liftM, when ) +import Text.Printf import Control.Applicative ((<$>), (*>), (<*), (<$)) import Data.Monoid +import Debug.Trace (trace) -- | Parse a Textile text and return a Pandoc document. readTextile :: ReaderOptions -- ^ Reader options @@ -135,9 +137,17 @@ blockParsers = [ codeBlock endBlock :: Parser [Char] ParserState Blocks endBlock = string "\n\n" >> return mempty + -- | Any block in the order of definition of blockParsers block :: Parser [Char] ParserState Blocks -block = choice blockParsers "block" +block = do + res <- choice blockParsers "block" + pos <- getPosition + tr <- getOption readerTrace + when tr $ + trace (printf "line %d: %s" (sourceLine pos) + (take 60 $ show $ B.toList res)) (return ()) + return res commentBlock :: Parser [Char] ParserState Blocks commentBlock = try $ do -- cgit v1.2.3