@@ -56,7 +56,7 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
5656import qualified Text.Pandoc.Builder as B
5757import Text.Pandoc.Options
5858import Text.Pandoc.Parsing
59−import Text.Pandoc.Readers.HTML ( htmlTag, isInlineTag, isBlockTag )
59+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag )
6060import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
6161import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
6262import Text.HTML.TagSoup.Match
@@ -133,12 +133,9 @@ blockParsers = [ codeBlock
133133 , rawLaTeXBlock'
134134 , maybeExplicitBlock "table" table
135135 , maybeExplicitBlock "p" para
136− , endBlock
136+ , mempty <$ blanklines
137137 ]
138138
139−endBlock :: Parser [Char] ParserState Blocks
140−endBlock = string "\n\n" >> return mempty
141−
142139-- | Any block in the order of definition of blockParsers
143140block :: Parser [Char] ParserState Blocks
144141block = do
@@ -193,7 +190,7 @@ header = try $ do
193190 attr <- attributes
194191 char '.'
195192 lookAhead whitespace
196− name <- trimInlines . mconcat <$> manyTill inline blockBreak
193+ name <- trimInlines . mconcat <$> many inline
197194 attr' <- registerHeader attr name
198195 return $ B.headerWith attr' level name
199196
@@ -304,17 +301,12 @@ definitionListItem = try $ do
304301 ds <- parseFromString parseBlocks (s ++ "\n\n")
305302 return [ds]
306303
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 ())
312−
313304-- raw content
314305
315306-- | A raw Html Block, optionally followed by blanklines
316307rawHtmlBlock :: Parser [Char] ParserState Blocks
317308rawHtmlBlock = try $ do
309+ skipMany spaceChar
318310 (_,b) <- htmlTag isBlockTag
319311 optional blanklines
320312 return $ B.rawBlock "html" b
@@ -328,7 +320,7 @@ rawLaTeXBlock' = do
328320
329321-- | In textile, paragraphs are separated by blank lines.
330322para :: Parser [Char] ParserState Blocks
331−para = B.para . trimInlines . mconcat <$> manyTill inline blockBreak
323+para = B.para . trimInlines . mconcat <$> many1 inline
332324
333325-- Tables
334326
@@ -505,11 +497,14 @@ whitespace = many1 spaceChar >> return B.space <?> "whitespace"
505497-- | In Textile, an isolated endline character is a line break
506498endline :: Parser [Char] ParserState Inlines
507499endline = try $ do
508− newline >> notFollowedBy blankline
500+ newline
501+ notFollowedBy blankline
502+ notFollowedBy listStart
503+ notFollowedBy rawHtmlBlock
509504 return B.linebreak
510505
511506rawHtmlInline :: Parser [Char] ParserState Inlines
512−rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag
507+rawHtmlInline = B.rawInline "html" . snd <$> htmlTag (const True)
513508
514509-- | Raw LaTeX Inline
515510rawLaTeXInline' :: Parser [Char] ParserState Inlines
@@ -561,7 +556,9 @@ escapedTag = B.str <$>
561556
562557-- | Any special symbol defined in wordBoundaries
563558symbol :: Parser [Char] ParserState Inlines
564−symbol = B.str . singleton <$> (oneOf wordBoundaries <|> oneOf markupChars)
559+symbol = B.str . singleton <$> (notFollowedBy newline *>
560+ notFollowedBy rawHtmlBlock *>
561+ oneOf wordBoundaries)
565562
566563-- | Inline code
567564code :: Parser [Char] ParserState Inlines