diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-19 13:22:15 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-19 13:30:48 +0300 |
commit | 1e21cfb251506d42cbdcf3e24661f08633817572 (patch) | |
tree | ff175b1a656600d5f4becb8bac07d203a7f006a8 | |
parent | ef8430e70269d0332f802986c9ef570faad8faa0 (diff) | |
download | pandoc-1e21cfb251506d42cbdcf3e24661f08633817572.tar.gz |
Muse writer: don't wrap note references to the next line
Closes #4172.
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 8 | ||||
-rw-r--r-- | test/command/4172.md | 29 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index ccda8edf1..545891d97 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -313,11 +313,17 @@ normalizeInlineList (Span a1 x1 : Span a2 x2 : ils) | a1 == a2 normalizeInlineList (x:xs) = x : normalizeInlineList xs normalizeInlineList [] = [] +fixNotes :: [Inline] -> [Inline] +fixNotes [] = [] +fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest +fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest +fixNotes (x:xs) = x : fixNotes xs + -- | Convert list of Pandoc inline elements to Muse. inlineListToMuse :: PandocMonad m => [Inline] -> StateT WriterState m Doc -inlineListToMuse lst = liftM hcat (mapM inlineToMuse (normalizeInlineList lst)) +inlineListToMuse lst = hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst) -- | Convert Pandoc inline element to Muse. inlineToMuse :: PandocMonad m diff --git a/test/command/4172.md b/test/command/4172.md new file mode 100644 index 000000000..6b497a87a --- /dev/null +++ b/test/command/4172.md @@ -0,0 +1,29 @@ +Test that text wrapping does not move note reference [1] to the beginning of the line, +where it would become a note. +``` +% pandoc -f muse -t muse +Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [1] a + +[1] b +^D +Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [1] +a + +[1] b + +``` + +SoftBreak test: +``` +% pandoc -f muse -t muse +Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + [1] a + +[1] b +^D +Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [1] +a + +[1] b + +``` |