Org reader: don't parse alphabetical lists...

...unless the `fancy_lists` extension is enabled.
Closes #9042.
This commit is contained in:
John MacFarlane
2023-08-30 22:01:00 -07:00
parent ed48998a89
commit 1e43eb46ce
3 changed files with 49 additions and 14 deletions
+18 -11
View File
@@ -29,6 +29,7 @@ import Text.Pandoc.Readers.Org.Parsing
import Text.Pandoc.Definition as Pandoc
import Text.Pandoc.Shared (safeRead)
import Text.Pandoc.Parsing (lowerAlpha, upperAlpha)
import Text.Pandoc.Extensions
import Data.Functor (($>))
-- | Horizontal Line (five -- dashes or more)
@@ -69,8 +70,7 @@ listCounterCookie = try $
<* char ']'
<* (skipSpaces <|> lookAhead eol)
where parseNum = (safeRead =<< many1Char digit)
<|> snd <$> lowerAlpha
<|> snd <$> upperAlpha
<|> snd <$> (lowerAlpha <|> upperAlpha)
bulletListStart :: Monad m => OrgParser m Int
bulletListStart = try $ do
@@ -87,20 +87,27 @@ eol = void (char '\n')
orderedListStart :: Monad m => OrgParser m (Int, ListAttributes)
orderedListStart = try $ do
ind <- length <$> many spaceChar
fancy <- option False $ True <$ guardEnabled Ext_fancy_lists
-- Ordered list markers allowed in org-mode
let styles = (many1Char digit $> (if fancy
then Decimal
else DefaultStyle))
: if fancy
then [ fst <$> lowerAlpha
, fst <$> upperAlpha ]
else []
let delims = [ char '.' $> (if fancy
then Period
else DefaultDelim)
, char ')' $> (if fancy
then OneParen
else DefaultDelim)
]
style <- choice styles
delim <- choice delims
skipSpaces1 <|> lookAhead eol
start <- option 1 listCounterCookie
return (ind + 1, (start, style, delim))
-- Ordered list markers allowed in org-mode
where
styles = [ many1Char digit $> Decimal
, fst <$> lowerAlpha
, fst <$> upperAlpha
]
delims = [ char '.' $> Period
, char ')' $> OneParen
]
drawerStart :: Monad m => OrgParser m Text
drawerStart = try $ skipSpaces *> drawerName <* skipSpaces <* newline
+1 -3
View File
@@ -853,9 +853,7 @@ indented indentedMarker minIndent = try $ do
orderedList :: PandocMonad m => OrgParser m (F Blocks)
orderedList = try $ do
(indent, attr) <- lookAhead orderedListStart
attr' <- option (fst3 attr, DefaultStyle, DefaultDelim) $
guardEnabled Ext_fancy_lists $> attr
fmap (B.orderedListWith attr' . compactify) . sequence
fmap (B.orderedListWith attr . compactify) . sequence
<$> many1 (listItem ((fst <$> orderedListStart) `indented` indent))
where fst3 (x,_,_) = x
+30
View File
@@ -0,0 +1,30 @@
```
% pandoc -f org
#+TITLE: Testing
* Testing
p. lower case
P. Upper Case
^D
<h1 id="testing-1">Testing</h1>
<p>p. lower case</p>
<p>P. Upper Case</p>
```
```
% pandoc -f org+fancy_lists
#+TITLE: Testing
* Testing
p. lower case
P. Upper Case
^D
<h1 id="testing-1">Testing</h1>
<ol type="a">
<li><p>lower case</p></li>
<li><p>Upper Case</p></li>
</ol>
```