diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-12 09:31:51 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-12 09:31:51 -0800 |
commit | af7e78243682ec7c353dd202590c45c734f86ada (patch) | |
tree | 731509a3ab17391a415bfb13c9798884569fe554 /src/Text/Pandoc | |
parent | d9c2f500bf636dca5b7f54548faf13dfd363c53b (diff) | |
download | pandoc-af7e78243682ec7c353dd202590c45c734f86ada.tar.gz |
Modified readers to emit SoftBreak when appropriate.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/CommonMark.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 12 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Txt2Tags.hs | 2 |
7 files changed, 19 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs index 7f752c446..71c7d05b2 100644 --- a/src/Text/Pandoc/Readers/CommonMark.hs +++ b/src/Text/Pandoc/Readers/CommonMark.hs @@ -103,7 +103,7 @@ addInline (Node _ (TEXT t) _) = (map toinl clumps ++) toinl (' ':_) = Space toinl xs = Str xs addInline (Node _ LINEBREAK _) = (LineBreak :) -addInline (Node _ SOFTBREAK _) = (Space :) +addInline (Node _ SOFTBREAK _) = (SoftBreak :) addInline (Node _ (INLINE_HTML t) _) = (RawInline (Format "html") (unpack t) :) addInline (Node _ (CODE t) _) = diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 85e9a0743..a34e2fb5c 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -799,7 +799,10 @@ pBad = do return $ B.str [c'] pSpace :: InlinesParser Inlines -pSpace = many1 (satisfy isSpace) >> return B.space +pSpace = many1 (satisfy isSpace) >>= \xs -> + if '\n' `elem` xs + then return B.softbreak + else return B.space -- -- Constants diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 6500cb29f..5a4612862 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -100,8 +100,13 @@ dimenarg = try $ do return $ ch ++ num ++ dim sp :: LP () -sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t') - <|> try (newline <* lookAhead anyChar <* notFollowedBy blankline) +sp = whitespace <|> endline + +whitespace :: LP () +whitespace = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t') + +endline :: LP () +endline = try (newline >> lookAhead anyChar >> notFollowedBy blankline) isLowerHex :: Char -> Bool isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f' @@ -196,7 +201,8 @@ singleQuote = do inline :: LP Inlines inline = (mempty <$ comment) - <|> (space <$ sp) + <|> (space <$ whitespace) + <|> (softbreak <$ endline) <|> inlineText <|> inlineCommand <|> inlineEnvironment diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 24b3f5c7e..e423720df 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -555,7 +555,8 @@ inlineHtml :: MWParser Inlines inlineHtml = B.rawInline "html" . snd <$> htmlTag isInlineTag' whitespace :: MWParser Inlines -whitespace = B.space <$ (skipMany1 spaceChar <|> endline <|> htmlComment) +whitespace = B.space <$ (skipMany1 spaceChar <|> htmlComment) + <|> B.softbreak <$ endline endline :: MWParser () endline = () <$ try (newline <* diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index 3be47cfd4..99a6927e2 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -1103,7 +1103,7 @@ endline = try $ do decEmphasisNewlinesCount guard =<< newlinesCountWithinLimits updateLastPreCharPos - return . return $ B.space + return . return $ B.softbreak cite :: OrgParser (F Inlines) cite = try $ do diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 0e5bb2a87..85f34d9d8 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1098,7 +1098,7 @@ endline = try $ do then notFollowedBy (anyOrderedListMarker >> spaceChar) >> notFollowedBy' bulletListStart else return () - return B.space + return B.softbreak -- -- links diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs index 58841f2ce..c28ce1653 100644 --- a/src/Text/Pandoc/Readers/Txt2Tags.hs +++ b/src/Text/Pandoc/Readers/Txt2Tags.hs @@ -550,7 +550,7 @@ endline = try $ do notFollowedBy quote notFollowedBy list notFollowedBy table - return $ B.space + return $ B.softbreak str :: T2T Inlines str = try $ do |