Muse writer: don't wrap note references to the next line

Closes #4172.
This commit is contained in:
Alexander Krotov 2017-12-19 13:22:15 +03:00
parent ef8430e702
commit 1e21cfb251
2 changed files with 36 additions and 1 deletions

View file

@ -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

29
test/command/4172.md Normal file
View file

@ -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
```