@@ -56,7 +56,7 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
56import qualified Text.Pandoc.Builder as B
56import qualified Text.Pandoc.Builder as B
57import Text.Pandoc.Options
57import Text.Pandoc.Options
58import Text.Pandoc.Parsing
58import Text.Pandoc.Parsing
59−import Text.Pandoc.Readers.HTML ( htmlTag, isInlineTag, isBlockTag )
59+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag )
60import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
60import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
61import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
61import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
62import Text.HTML.TagSoup.Match
62import Text.HTML.TagSoup.Match
@@ -133,12 +133,9 @@ blockParsers = [ codeBlock
133 , rawLaTeXBlock'
133 , rawLaTeXBlock'
134 , maybeExplicitBlock "table" table
134 , maybeExplicitBlock "table" table
135 , maybeExplicitBlock "p" para
135 , maybeExplicitBlock "p" para
136− , endBlock
136+ , mempty <$ blanklines
139−endBlock :: Parser [Char] ParserState Blocks
140−endBlock = string "\n\n" >> return mempty
142-- | Any block in the order of definition of blockParsers
139-- | Any block in the order of definition of blockParsers
143block :: Parser [Char] ParserState Blocks
140block :: Parser [Char] ParserState Blocks
144block = do
141block = do
@@ -193,7 +190,7 @@ header = try $ do
193 attr <- attributes
190 attr <- attributes
195 lookAhead whitespace
192 lookAhead whitespace
196− name <- trimInlines . mconcat <$> manyTill inline blockBreak
193+ name <- trimInlines . mconcat <$> many inline
197 attr' <- registerHeader attr name
194 attr' <- registerHeader attr name
198 return $ B.headerWith attr' level name
195 return $ B.headerWith attr' level name
@@ -304,17 +301,12 @@ definitionListItem = try $ do
304 ds <- parseFromString parseBlocks (s ++ "\n\n")
301 ds <- parseFromString parseBlocks (s ++ "\n\n")
305 return [ds]
302 return [ds]
307−-- | This terminates a block such as a paragraph. Because of raw html
308−-- blocks support, we have to lookAhead for a rawHtmlBlock.
309−blockBreak :: Parser [Char] ParserState ()
310−blockBreak = try (newline >> blanklines >> return ()) <|>
311− try (optional spaces >> lookAhead rawHtmlBlock >> return ())
313-- raw content
304-- raw content
315-- | A raw Html Block, optionally followed by blanklines
306-- | A raw Html Block, optionally followed by blanklines
316rawHtmlBlock :: Parser [Char] ParserState Blocks
307rawHtmlBlock :: Parser [Char] ParserState Blocks
317rawHtmlBlock = try $ do
308rawHtmlBlock = try $ do
318 (_,b) <- htmlTag isBlockTag
310 (_,b) <- htmlTag isBlockTag
319 optional blanklines
311 optional blanklines
320 return $ B.rawBlock "html" b
312 return $ B.rawBlock "html" b
@@ -328,7 +320,7 @@ rawLaTeXBlock' = do
329-- | In textile, paragraphs are separated by blank lines.
321-- | In textile, paragraphs are separated by blank lines.
330para :: Parser [Char] ParserState Blocks
322para :: Parser [Char] ParserState Blocks
331−para = B.para . trimInlines . mconcat <$> manyTill inline blockBreak
323+para = B.para . trimInlines . mconcat <$> many1 inline
@@ -505,11 +497,14 @@ whitespace = many1 spaceChar >> return B.space <?> "whitespace"
505-- | In Textile, an isolated endline character is a line break
497-- | In Textile, an isolated endline character is a line break
506endline :: Parser [Char] ParserState Inlines
498endline :: Parser [Char] ParserState Inlines
507endline = try $ do
499endline = try $ do
508− newline >> notFollowedBy blankline
501+ notFollowedBy blankline
502+ notFollowedBy listStart
503+ notFollowedBy rawHtmlBlock
509 return B.linebreak
504 return B.linebreak
511rawHtmlInline :: Parser [Char] ParserState Inlines
506rawHtmlInline :: Parser [Char] ParserState Inlines
512−rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag
507+rawHtmlInline = B.rawInline "html" . snd <$> htmlTag (const True)
514-- | Raw LaTeX Inline
509-- | Raw LaTeX Inline
515rawLaTeXInline' :: Parser [Char] ParserState Inlines
510rawLaTeXInline' :: Parser [Char] ParserState Inlines
@@ -561,7 +556,9 @@ escapedTag = B.str <$>
562-- | Any special symbol defined in wordBoundaries
557-- | Any special symbol defined in wordBoundaries
563symbol :: Parser [Char] ParserState Inlines
558symbol :: Parser [Char] ParserState Inlines
559+symbol = B.str . singleton <$> (notFollowedBy newline *>
560+ notFollowedBy rawHtmlBlock *>
564−symbol = B.str . singleton <$> (oneOf wordBoundaries <|> oneOf markupChars)
561+ oneOf wordBoundaries)
566-- | Inline code
563-- | Inline code
567code :: Parser [Char] ParserState Inlines
564code :: Parser [Char] ParserState Inlines