git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: don't allow optional * on symbol control sequences.

Generally we allow optional starred variants of LaTeX commands (since many allow them, and if we don't accept these explicitly, ignoring the star usually gives acceptable results). But we don't want to do this for `\(*\)` and similar cases. Closes #7340.

commitabb59bd58222c67fd36a8e447c01de3404a7ed1d authorJohn MacFarlane <jgm@berkeley.edu> dateTue 1 Jun 2021, 13:54 (5 years ago) parent7225d4a
2 files changed+10−2
src/Text/Pandoc/Readers/LaTeX.hs+4−2 test/command/7340.md+6
src/Text/Pandoc/Readers/LaTeX.hs+4−2
@@ -24,7 +24,7 @@ module Text.Pandoc.Readers.LaTeX ( readLaTeX,
2424import Control.Applicative (many, optional, (<|>))
2525import Control.Monad
2626import Control.Monad.Except (throwError)
27−import Data.Char (isDigit, isLetter, toUpper, chr)
27+import Data.Char (isDigit, isLetter, isAlphaNum, toUpper, chr)
2828import Data.Default
2929import Data.List (intercalate)
3030import qualified Data.Map as M
@@ -300,7 +300,9 @@ inlineCommand' :: PandocMonad m => LP m Inlines
300300inlineCommand' = try $ do
301301 Tok _ (CtrlSeq name) cmd <- anyControlSeq
302302 guard $ name /= "begin" && name /= "end" && name /= "and"
303− star <- option "" ("*" <$ symbol '*' <* sp)
303+ star <- if T.all isAlphaNum name
304+ then option "" ("*" <$ symbol '*' <* sp)
305+ else pure ""
304306 overlay <- option "" overlaySpecification
305307 let name' = name <> star <> overlay
306308 let names = ordNub [name', name] -- check non-starred as fallback
test/command/7340.mdnew file+6
@@ -0,0 +1,6 @@
1+```
2+% pandoc -f latex -t native
3+\(*\)
4+^D
5+[Para [Math InlineMath "*"]]
6+```