diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-08-30 22:01:00 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-08-30 22:01:41 -0700 |
| commit | 1e43eb46ce3156ef72b5890d64af17c81ef6c580 (patch) | |
| tree | caea2fa3c03a26105a8289dd5dd9842aa9167545 | |
| parent | ed48998a89c4f589c7c17621d26400f70f7b5aa4 (diff) | |
Org reader: don't parse alphabetical lists...
...unless the `fancy_lists` extension is enabled.
Closes #9042.
| -rw-r--r-- | src/Text/Pandoc/Readers/Org/BlockStarts.hs | 29 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 4 | ||||
| -rw-r--r-- | test/command/9042.md | 30 |
3 files changed, 49 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/Org/BlockStarts.hs b/src/Text/Pandoc/Readers/Org/BlockStarts.hs index 5a2667289..c917756ef 100644 --- a/src/Text/Pandoc/Readers/Org/BlockStarts.hs +++ b/src/Text/Pandoc/Readers/Org/BlockStarts.hs @@ -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 diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 79f0e1238..c1e023e58 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -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 diff --git a/test/command/9042.md b/test/command/9042.md new file mode 100644 index 000000000..a27fa8023 --- /dev/null +++ b/test/command/9042.md @@ -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> +``` |
