diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-21 16:36:29 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-21 16:36:29 +0300 |
commit | d035689a0646261d7a4731e39bce7dbf85187773 (patch) | |
tree | 6488bec057f75aac850d39818852ac9a68ec6b70 | |
parent | 0405c5b461ee8d9a57eacc5ff2b44fafa5c0637f (diff) | |
download | pandoc-d035689a0646261d7a4731e39bce7dbf85187773.tar.gz |
Org writer: do not wrap "-" to avoid accidental bullet lists
Also add TODO for ordered lists.
-rw-r--r-- | src/Text/Pandoc/Writers/Org.hs | 19 | ||||
-rw-r--r-- | test/command/4171.md | 9 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index e10fcd5ce..43b5b59ee 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -308,13 +308,18 @@ blockListToOrg blocks = vcat <$> mapM blockToOrg blocks inlineListToOrg :: PandocMonad m => [Inline] -> Org m Doc -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 (SoftBreak : n@Note{} : rest) = - Str " " : n : fixNotes rest - fixNotes (x : rest) = x : fixNotes rest +inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixMarkers lst) + where fixMarkers [] = [] -- prevent note refs and list markers from wrapping, see #4171 + fixMarkers (Space : x : rest) | shouldFix x = + Str " " : x : fixMarkers rest + fixMarkers (SoftBreak : x : rest) | shouldFix x = + Str " " : x : fixMarkers rest + fixMarkers (x : rest) = x : fixMarkers rest + + shouldFix Note{} = True -- Prevent footnotes + shouldFix (Str "-") = True -- Prevent bullet list items + -- TODO: prevent ordered list items + shouldFix _ = False -- | Convert Pandoc inline element to Org. inlineToOrg :: PandocMonad m => Inline -> Org m Doc diff --git a/test/command/4171.md b/test/command/4171.md index 3256d4673..42b4576e3 100644 --- a/test/command/4171.md +++ b/test/command/4171.md @@ -23,3 +23,12 @@ a [fn:1] b ``` + +Similar bug: "-" should not be wrapped: +``` +% pandoc -f org -t org +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - abc +^D +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - +abc +``` |