git.iko.soy/typeable/pandoc
on master help sign in
Org writer: do not wrap "-" to avoid accidental bullet lists

Also add TODO for ordered lists.

commitd035689a0646261d7a4731e39bce7dbf85187773 authorAlexander Krotov <ilabdsf@gmail.com> dateThu 21 Dec 2017, 16:36 (9 years ago) parent0405c5b
2 files changed+21−7
src/Text/Pandoc/Writers/Org.hs+12−7 test/command/4171.md+9
src/Text/Pandoc/Writers/Org.hs+12−7
@@ -308,13 +308,18 @@ blockListToOrg blocks = vcat <$> mapM blockToOrg blocks
308308inlineListToOrg :: PandocMonad m
309309 => [Inline]
310310 -> Org m Doc
311−inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixNotes lst)
312− where fixNotes [] = [] -- prevent note ref from wrapping, see #4171
313− fixNotes (Space : n@Note{} : rest) =
314− Str " " : n : fixNotes rest
315− fixNotes (SoftBreak : n@Note{} : rest) =
316− Str " " : n : fixNotes rest
317− fixNotes (x : rest) = x : fixNotes rest
311+inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixMarkers lst)
312+ where fixMarkers [] = [] -- prevent note refs and list markers from wrapping, see #4171
313+ fixMarkers (Space : x : rest) | shouldFix x =
314+ Str " " : x : fixMarkers rest
315+ fixMarkers (SoftBreak : x : rest) | shouldFix x =
316+ Str " " : x : fixMarkers rest
317+ fixMarkers (x : rest) = x : fixMarkers rest
318+
319+ shouldFix Note{} = True -- Prevent footnotes
320+ shouldFix (Str "-") = True -- Prevent bullet list items
321+ -- TODO: prevent ordered list items
322+ shouldFix _ = False
318323
319324-- | Convert Pandoc inline element to Org.
320325inlineToOrg :: PandocMonad m => Inline -> Org m Doc
test/command/4171.md+9
@@ -23,3 +23,12 @@ a
2323
2424[fn:1] b
2525```
26+
27+Similar bug: "-" should not be wrapped:
28+```
29+% pandoc -f org -t org
30+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - abc
31+^D
32+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -
33+abc
34+```