aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Org.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-03-09 18:01:08 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2021-03-09 18:14:54 +0100
commitb9b2586ed3e9aac9c5ba86127fbf984fb3149844 (patch)
tree1834951682b1a947739bed022c674837207a10c8 /src/Text/Pandoc/Writers/Org.hs
parent0515c448592e2b24f79e8a7bd249b396f4f0da62 (diff)
downloadpandoc-b9b2586ed3e9aac9c5ba86127fbf984fb3149844.tar.gz
Org writer: prevent unintended creation of ordered list items
Adjust line wrapping if default wrapping would cause a line to be read as an ordered list item. Fixes #7132
Diffstat (limited to 'src/Text/Pandoc/Writers/Org.hs')
-rw-r--r--src/Text/Pandoc/Writers/Org.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index 8dfc2749c..1b525831e 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -17,7 +17,7 @@ Org-Mode: <http://orgmode.org>
-}
module Text.Pandoc.Writers.Org (writeOrg) where
import Control.Monad.State.Strict
-import Data.Char (isAlphaNum)
+import Data.Char (isAlphaNum, isDigit)
import Data.List (intersect, intersperse, partition, transpose)
import Data.Text (Text)
import qualified Data.Text as T
@@ -347,16 +347,19 @@ inlineListToOrg :: PandocMonad m
=> [Inline]
-> Org m (Doc Text)
inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixMarkers lst)
- where fixMarkers [] = [] -- prevent note refs and list markers from wrapping, see #4171
+ where -- Prevent note refs and list markers from wrapping, see #4171
+ -- and #7132.
+ fixMarkers [] = []
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 Note{} = True -- Prevent footnotes
shouldFix (Str "-") = True -- Prevent bullet list items
- -- TODO: prevent ordered list items
+ shouldFix (Str x) -- Prevent ordered list items
+ | Just (cs, c) <- T.unsnoc x = T.all isDigit cs && c == '.' || c == ')'
shouldFix _ = False
-- | Convert Pandoc inline element to Org.