Org writer: don't allow fn refs to wrap to beginning of line.

Otherwise they can be interpreted as footnote definitions.

Closes #4171.
This commit is contained in:
John MacFarlane 2017-12-18 16:31:32 -08:00
parent 70dc5834da
commit c0cc9270cb
2 changed files with 16 additions and 1 deletions

View file

@ -308,7 +308,11 @@ blockListToOrg blocks = vcat <$> mapM blockToOrg blocks
inlineListToOrg :: PandocMonad m
=> [Inline]
-> Org m Doc
inlineListToOrg lst = hcat <$> mapM inlineToOrg lst
inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixNotes lst)
where fixNotes [] = [] -- prevent note ref from wrapping, see #4171
fixNotes (Space : n@Note{} : rest) =
Str " " : n : fixNotes rest
fixNotes (x : rest) = x : fixNotes rest
-- | Convert Pandoc inline element to Org.
inlineToOrg :: PandocMonad m => Inline -> Org m Doc

11
test/command/4171.md Normal file
View file

@ -0,0 +1,11 @@
```
% pandoc -f org -t org
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [fn:1] a
[fn:1] b
^D
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [fn:1]
a
[fn:1] b
```