aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorPaul Rivier <paul.r.ml@gmail.com>2010-11-23 12:09:04 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-03 23:10:51 -0800
commitd724c6b5681b2f5815b7d915d5e39a7d3979e7f8 (patch)
treeda67082fda81cbee917ebbe990abf7daddb8cc24 /src/Text/Pandoc/Readers
parentfa0866886be778b0157340ea0563b6744424cfa6 (diff)
downloadpandoc-d724c6b5681b2f5815b7d915d5e39a7d3979e7f8.tar.gz
html inlines and html blocks handling in textile reader
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index 96df3dd04..aec8b48a8 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion from Textile to 'Pandoc' document, based on the spec
available at ahttp://redcloth.org/hobix.com/textile/
-Implemented and parsed :
+Implemented and parsed:
- Paragraphs
- Code blocks
- Lists
@@ -36,8 +36,14 @@ Implemented and parsed :
- Inlines : strong, emph, cite, code, deleted, superscript,
subscript, links
-Implemented but discarded :
+Implemented but discarded:
- HTML-specific and CSS-specific attributes
+
+Left to be implemented:
+ - Pandoc Meta Information (title, author, date)
+ - footnotes
+ - should autolink be shared through Parsing.hs ?
+
-}
@@ -47,7 +53,8 @@ module Text.Pandoc.Readers.Textile (
import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
-import Text.Pandoc.Readers.HTML ( htmlTag, htmlEndTag )
+import Text.Pandoc.Readers.HTML ( htmlTag, htmlEndTag, -- find code blocks
+ rawHtmlBlock, rawHtmlInline )
import Text.ParserCombinators.Parsec
import Data.Char ( digitToInt )
@@ -83,6 +90,7 @@ blockParsers = [ codeBlock
, header
, blockQuote
, anyList
+ , rawHtmlBlock'
, maybeExplicitBlock "table" table
, maybeExplicitBlock "p" para
, nullBlock ]
@@ -170,17 +178,26 @@ orderedListItemAtDepth depth = try $ do
sublist <- option [] (anyListAtDepth (depth + 1) >>= return . (:[]))
return (p:sublist)
--- | This terminates a block such as a paragraph.
+-- | This terminates a block such as a paragraph. Because of raw html
+-- blocks support, we have to lookAhead for a rawHtmlBlock.
blockBreak :: GenParser Char ParserState ()
-blockBreak = try $ newline >> blanklines >> return ()
+blockBreak = try $ choice
+ [newline >> blanklines >> return (),
+ lookAhead rawHtmlBlock' >> return ()]
+-- | A raw Html Block, optionally followed by blanklines
+rawHtmlBlock' :: GenParser Char ParserState Block
+rawHtmlBlock' = try $ do
+ b <- rawHtmlBlock
+ optional blanklines
+ return b
-- | In textile, paragraphs are separated by blank lines.
para :: GenParser Char ParserState Block
para = try $ do
content <- manyTill inline blockBreak
return $ Para $ normalizeSpaces content
-
+
-- Tables
@@ -260,6 +277,7 @@ inlineParsers = [ autoLink
, str
, whitespace
, endline
+ , rawHtmlInline
, code
, simpleInline (string "??") (Cite [])
, simpleInline (string "**") Strong
@@ -313,7 +331,7 @@ image = try $ do
-- | Any special symbol defined in specialChars
symbol :: GenParser Char ParserState Inline
-symbol = do
+symbol = do
result <- oneOf specialChars
return $ Str [result]
@@ -322,7 +340,6 @@ code :: GenParser Char ParserState Inline
code = surrounded (char '@') anyChar >>=
return . Code
-
-- | Html / CSS attributes
attributes :: GenParser Char ParserState String
attributes = choice [ enclosed (char '(') (char ')') anyChar,
@@ -341,12 +358,4 @@ simpleInline :: GenParser Char ParserState t -- ^ surrounding parser
-> GenParser Char ParserState Inline -- ^ content parser (to be used repeatedly)
simpleInline border construct = surrounded border (inlineWithAttribute) >>=
return . construct . normalizeSpaces
- where inlineWithAttribute = (try $ optional attributes) >> inline
-
-
--- TODO
---
--- - Pandoc Meta Information (title, author, date)
--- - footnotes
--- - should autolink be shared through Parsing.hs ?
--- - embeded HTML, both inlines and blocks
+ where inlineWithAttribute = (try $ optional attributes) >> inline \ No newline at end of file