git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: produce SoftBreaks on newlines
163af3fAlexander Krotov
src/Text/Pandoc/Readers/Muse.hs+28−18
@@ -556,25 +556,35 @@ tableParseCaption = try $ do
556-- inline parsers
556-- inline parsers
557--
557--
558
558
559+inlineList :: PandocMonad m => [MuseParser m (F Inlines)]
560+inlineList = [ endline
561+ , br
562+ , anchor
563+ , footnote
564+ , strong
565+ , strongTag
566+ , emph
567+ , emphTag
568+ , superscriptTag
569+ , subscriptTag
570+ , strikeoutTag
571+ , verbatimTag
572+ , link
573+ , code
574+ , codeTag
575+ , whitespace
576+ , str
577+ , symbol
578+ ]
579+
559inline :: PandocMonad m => MuseParser m (F Inlines)
580inline :: PandocMonad m => MuseParser m (F Inlines)
560−inline = choice [ br
581+inline = (choice inlineList) <?> "inline"
561− , anchor
582+
562− , footnote
583+endline :: PandocMonad m => MuseParser m (F Inlines)
563− , strong
584+endline = try $ do
564− , strongTag
585+ newline
565− , emph
586+ notFollowedBy blankline
566− , emphTag
587+ returnF B.softbreak
567− , superscriptTag
568− , subscriptTag
569− , strikeoutTag
570− , verbatimTag
571− , link
572− , code
573− , codeTag
574− , whitespace
575− , str
576− , symbol
577− ] <?> "inline"
578
588
579anchor :: PandocMonad m => MuseParser m (F Inlines)
589anchor :: PandocMonad m => MuseParser m (F Inlines)
580anchor = try $ do
590anchor = try $ do
test/Tests/Readers/Muse.hs+13−13
@@ -76,7 +76,7 @@ tests =
76 , ""
76 , ""
77 , "Fourth line</em>"
77 , "Fourth line</em>"
78 ] =?>
78 ] =?>
79− para "First line <em>Second line" <>
79+ para "First line\n<em>Second line" <>
80 para "Fourth line</em>"
80 para "Fourth line</em>"
81
81
82 , "Linebreak" =: "Line <br> break" =?> para ("Line" <> linebreak <> "break")
82 , "Linebreak" =: "Line <br> break" =?> para ("Line" <> linebreak <> "break")
@@ -168,12 +168,12 @@ tests =
168 T.unlines [ "First line"
168 T.unlines [ "First line"
169 , "second line."
169 , "second line."
170 ] =?>
170 ] =?>
171− para "First line second line."
171+ para "First line\nsecond line."
172 , "Indented paragraph" =:
172 , "Indented paragraph" =:
173 T.unlines [ " First line"
173 T.unlines [ " First line"
174 , "second line."
174 , "second line."
175 ] =?>
175 ] =?>
176− para "First line second line."
176+ para "First line\nsecond line."
177 -- Emacs Muse starts a blockquote on the second line.
177 -- Emacs Muse starts a blockquote on the second line.
178 -- We copy Amusewiki behavior and require a blank line to start a blockquote.
178 -- We copy Amusewiki behavior and require a blank line to start a blockquote.
179 , "Indentation in the middle of paragraph" =:
179 , "Indentation in the middle of paragraph" =:
@@ -181,7 +181,7 @@ tests =
181 , " second line"
181 , " second line"
182 , "third line"
182 , "third line"
183 ] =?>
183 ] =?>
184− para "First line second line third line"
184+ para "First line\nsecond line\nthird line"
185 , "Quote" =:
185 , "Quote" =:
186 " This is a quotation\n" =?>
186 " This is a quotation\n" =?>
187 blockQuote (para "This is a quotation")
187 blockQuote (para "This is a quotation")
@@ -189,7 +189,7 @@ tests =
189 T.unlines [ " This is a quotation"
189 T.unlines [ " This is a quotation"
190 , " with a continuation"
190 , " with a continuation"
191 ] =?>
191 ] =?>
192− blockQuote (para "This is a quotation with a continuation")
192+ blockQuote (para "This is a quotation\nwith a continuation")
193 , testGroup "Div"
193 , testGroup "Div"
194 [ "Div without id" =:
194 [ "Div without id" =:
195 "<div>Foo bar</div>" =?>
195 "<div>Foo bar</div>" =?>
@@ -359,7 +359,7 @@ tests =
359 T.unlines [ "Paragraph starts here"
359 T.unlines [ "Paragraph starts here"
360 , "#anchor and ends here."
360 , "#anchor and ends here."
361 ] =?>
361 ] =?>
362− para ("Paragraph starts here " <> spanWith ("anchor", [], []) mempty <> "and ends here.")
362+ para ("Paragraph starts here\n" <> spanWith ("anchor", [], []) mempty <> "and ends here.")
363 ]
363 ]
364 , testGroup "Footnotes"
364 , testGroup "Footnotes"
365 [ "Simple footnote" =:
365 [ "Simple footnote" =:
@@ -408,7 +408,7 @@ tests =
408 ] =?>
408 ] =?>
409 para (text "First footnote reference" <>
409 para (text "First footnote reference" <>
410 note (para "First footnote paragraph" <>
410 note (para "First footnote paragraph" <>
411− para "Second footnote paragraph") <>
411+ para "Second footnote\nparagraph") <>
412 text " and second footnote reference" <>
412 text " and second footnote reference" <>
413 note (para "Third footnote paragraph" <>
413 note (para "Third footnote paragraph" <>
414 para "Fourth footnote paragraph") <>
414 para "Fourth footnote paragraph") <>
@@ -597,7 +597,7 @@ tests =
597 , " bar"
597 , " bar"
598 , " - Baz"
598 , " - Baz"
599 ] =?>
599 ] =?>
600− bulletList [ para "Foo bar"
600+ bulletList [ para "Foo\nbar"
601 , para "Baz"
601 , para "Baz"
602 ]
602 ]
603 , "One blank line after multiline first item" =:
603 , "One blank line after multiline first item" =:
@@ -607,7 +607,7 @@ tests =
607 , ""
607 , ""
608 , " - Baz"
608 , " - Baz"
609 ] =?>
609 ] =?>
610− bulletList [ para "Foo bar"
610+ bulletList [ para "Foo\nbar"
611 , para "Baz"
611 , para "Baz"
612 ]
612 ]
613 , "Two blank lines after multiline first item" =:
613 , "Two blank lines after multiline first item" =:
@@ -618,7 +618,7 @@ tests =
618 , ""
618 , ""
619 , " - Baz"
619 , " - Baz"
620 ] =?>
620 ] =?>
621− bulletList [ para "Foo bar" ] <> bulletList [ para "Baz" ]
621+ bulletList [ para "Foo\nbar" ] <> bulletList [ para "Baz" ]
622 , "No blank line after list continuation" =:
622 , "No blank line after list continuation" =:
623 T.unlines
623 T.unlines
624 [ " - Foo"
624 [ " - Foo"
@@ -658,7 +658,7 @@ tests =
658 [ "First :: second"
658 [ "First :: second"
659 , "Foo :: bar"
659 , "Foo :: bar"
660 ] =?>
660 ] =?>
661− para "First :: second Foo :: bar"
661+ para "First :: second\nFoo :: bar"
662 , test emacsMuse "Emacs Muse definition list"
662 , test emacsMuse "Emacs Muse definition list"
663 (T.unlines
663 (T.unlines
664 [ "First :: second"
664 [ "First :: second"
@@ -688,7 +688,7 @@ tests =
688 , "and its continuation."
688 , "and its continuation."
689 , " Second term :: Definition of second term."
689 , " Second term :: Definition of second term."
690 ] =?>
690 ] =?>
691− definitionList [ ("First term", [ para "Definition of first term and its continuation." ])
691+ definitionList [ ("First term", [ para "Definition of first term\nand its continuation." ])
692 , ("Second term", [ para "Definition of second term." ])
692 , ("Second term", [ para "Definition of second term." ])
693 ]
693 ]
694 -- Emacs Muse creates two separate lists when indentation of items is different.
694 -- Emacs Muse creates two separate lists when indentation of items is different.
@@ -699,7 +699,7 @@ tests =
699 , "and its continuation."
699 , "and its continuation."
700 , " Second term :: Definition of second term."
700 , " Second term :: Definition of second term."
701 ] =?>
701 ] =?>
702− definitionList [ ("First term", [ para "Definition of first term and its continuation." ])
702+ definitionList [ ("First term", [ para "Definition of first term\nand its continuation." ])
703 , ("Second term", [ para "Definition of second term." ])
703 , ("Second term", [ para "Definition of second term." ])
704 ]
704 ]
705 , "Two blank lines separate definition lists" =:
705 , "Two blank lines separate definition lists" =: