git.iko.soy/typeable/pandoc
on master help sign in
Modified readers to emit SoftBreak when appropriate.
commitaf7e78243682ec7c353dd202590c45c734f86ada authorJohn MacFarlane <jgm@berkeley.edu> dateSat 12 Dec 2015, 09:31 (11 years ago) parentd9c2f50
14 files changed+26−16
src/Text/Pandoc/Readers/CommonMark.hs+1−1 src/Text/Pandoc/Readers/HTML.hs+4−1 src/Text/Pandoc/Readers/LaTeX.hs+9−3 src/Text/Pandoc/Readers/MediaWiki.hs+2−1 src/Text/Pandoc/Readers/Org.hs+1−1 src/Text/Pandoc/Readers/RST.hs+1−1 src/Text/Pandoc/Readers/Txt2Tags.hs+1−1 stack.yaml+1−1 tests/testsuite.native+1−1 tests/writer.docbook+1−1 tests/writer.dokuwiki+1−1 tests/writer.html+1−1 tests/writer.mediawiki+1−1 tests/writer.textile+1−1
src/Text/Pandoc/Readers/CommonMark.hs+1−1
@@ -103,7 +103,7 @@ addInline (Node _ (TEXT t) _) = (map toinl clumps ++)
103103 toinl (' ':_) = Space
104104 toinl xs = Str xs
105105addInline (Node _ LINEBREAK _) = (LineBreak :)
106−addInline (Node _ SOFTBREAK _) = (Space :)
106+addInline (Node _ SOFTBREAK _) = (SoftBreak :)
107107addInline (Node _ (INLINE_HTML t) _) =
108108 (RawInline (Format "html") (unpack t) :)
109109addInline (Node _ (CODE t) _) =
src/Text/Pandoc/Readers/HTML.hs+4−1
@@ -799,7 +799,10 @@ pBad = do
799799 return $ B.str [c']
800800
801801pSpace :: InlinesParser Inlines
802−pSpace = many1 (satisfy isSpace) >> return B.space
802+pSpace = many1 (satisfy isSpace) >>= \xs ->
803+ if '\n' `elem` xs
804+ then return B.softbreak
805+ else return B.space
803806
804807--
805808-- Constants
src/Text/Pandoc/Readers/LaTeX.hs+9−3
@@ -100,8 +100,13 @@ dimenarg = try $ do
100100 return $ ch ++ num ++ dim
101101
102102sp :: LP ()
103−sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
104− <|> try (newline <* lookAhead anyChar <* notFollowedBy blankline)
103+sp = whitespace <|> endline
104+
105+whitespace :: LP ()
106+whitespace = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
107+
108+endline :: LP ()
109+endline = try (newline >> lookAhead anyChar >> notFollowedBy blankline)
105110
106111isLowerHex :: Char -> Bool
107112isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
@@ -196,7 +201,8 @@ singleQuote = do
196201
197202inline :: LP Inlines
198203inline = (mempty <$ comment)
199− <|> (space <$ sp)
204+ <|> (space <$ whitespace)
205+ <|> (softbreak <$ endline)
200206 <|> inlineText
201207 <|> inlineCommand
202208 <|> inlineEnvironment
src/Text/Pandoc/Readers/MediaWiki.hs+2−1
@@ -555,7 +555,8 @@ inlineHtml :: MWParser Inlines
555555inlineHtml = B.rawInline "html" . snd <$> htmlTag isInlineTag'
556556
557557whitespace :: MWParser Inlines
558−whitespace = B.space <$ (skipMany1 spaceChar <|> endline <|> htmlComment)
558+whitespace = B.space <$ (skipMany1 spaceChar <|> htmlComment)
559+ <|> B.softbreak <$ endline
559560
560561endline :: MWParser ()
561562endline = () <$ try (newline <*
src/Text/Pandoc/Readers/Org.hs+1−1
@@ -1103,7 +1103,7 @@ endline = try $ do
11031103 decEmphasisNewlinesCount
11041104 guard =<< newlinesCountWithinLimits
11051105 updateLastPreCharPos
1106− return . return $ B.space
1106+ return . return $ B.softbreak
11071107
11081108cite :: OrgParser (F Inlines)
11091109cite = try $ do
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -1098,7 +1098,7 @@ endline = try $ do
10981098 then notFollowedBy (anyOrderedListMarker >> spaceChar) >>
10991099 notFollowedBy' bulletListStart
11001100 else return ()
1101− return B.space
1101+ return B.softbreak
11021102
11031103--
11041104-- links
src/Text/Pandoc/Readers/Txt2Tags.hs+1−1
@@ -550,7 +550,7 @@ endline = try $ do
550550 notFollowedBy quote
551551 notFollowedBy list
552552 notFollowedBy table
553− return $ B.space
553+ return $ B.softbreak
554554
555555str :: T2T Inlines
556556str = try $ do
stack.yaml+1−1
@@ -9,7 +9,7 @@ packages:
99- '.'
1010- location:
1111 git: 'https://github.com/jgm/pandoc-types'
12− commit: c46ab17eb17e16c3401a4ed48fc93e034a92b850
12+ commit: 8aba9332f56fd23bc3c06065193abe5ace3e70b4
1313 extra-dep: true
1414- location:
1515 git: 'https://github.com/jgm/texmath'
tests/testsuite.native+1−1
@@ -260,7 +260,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
260260,Div ("",[],[])
261261 [Div ("",[],[])
262262 [Div ("",[],[])
263− [Plain [Str "foo",SoftBreak]]]]
263+ [Plain [Str "foo"]]]]
264264,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
265265,RawBlock (Format "html") "<!-- Comment -->"
266266,Para [Str "Multiline:"]
tests/writer.docbook+1−1
@@ -912,7 +912,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
912912 Now, nested:
913913 </para>
914914 <para>
915− foo
915+ foo
916916 </para>
917917 <para>
918918 This should just be an HTML comment:
tests/writer.dokuwiki+1−1
@@ -350,7 +350,7 @@ As should this:
350350</code>
351351Now, nested:
352352
353−foo
353+foo
354354
355355
356356
tests/writer.html+1−1
@@ -362,7 +362,7 @@ And this is <strong>strong</strong>
362362<div>
363363<div>
364364<div>
365−foo
365+foo
366366</div>
367367</div>
368368</div>
tests/writer.mediawiki+1−1
@@ -374,7 +374,7 @@ Now, nested:
374374
375375<div>
376376
377−foo
377+foo
378378
379379</div>
380380
tests/writer.textile+1−1
@@ -424,7 +424,7 @@ Now, nested:
424424
425425<div>
426426
427−foo
427+foo
428428
429429</div>
430430