git.iko.soy/typeable/pandoc
on master help sign in
Org writer: do not wrap "-" to avoid accidental bullet lists
d035689Alexander Krotov
src/Text/Pandoc/Writers/Org.hs+12−7
@@ -308,13 +308,18 @@ blockListToOrg blocks = vcat <$> mapM blockToOrg blocks
308inlineListToOrg :: PandocMonad m
308inlineListToOrg :: PandocMonad m
309 => [Inline]
309 => [Inline]
310 -> Org m Doc
310 -> Org m Doc
311−inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixNotes lst)
311+inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixMarkers lst)
312− where fixNotes [] = [] -- prevent note ref from wrapping, see #4171
312+ where fixMarkers [] = [] -- prevent note refs and list markers from wrapping, see #4171
313− fixNotes (Space : n@Note{} : rest) =
313+ fixMarkers (Space : x : rest) | shouldFix x =
314− Str " " : n : fixNotes rest
314+ Str " " : x : fixMarkers rest
315− fixNotes (SoftBreak : n@Note{} : rest) =
315+ fixMarkers (SoftBreak : x : rest) | shouldFix x =
316− Str " " : n : fixNotes rest
316+ Str " " : x : fixMarkers rest
317− fixNotes (x : rest) = x : fixNotes 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
318
323
319-- | Convert Pandoc inline element to Org.
324-- | Convert Pandoc inline element to Org.
320inlineToOrg :: PandocMonad m => Inline -> Org m Doc
325inlineToOrg :: PandocMonad m => Inline -> Org m Doc
test/command/4171.md+9
@@ -23,3 +23,12 @@ a
23
23
24[fn:1] b
24[fn:1] b
25```
25```
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+```