Org writer: avoid = delimiter for inline code containing =.

Org has no escape mechanism inside verbatim text, so `=code with ==`
did not parse as verbatim. Fall back to the equivalent `~...~`
delimiter when the content contains `=` (and no `~`).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-20 10:28:30 -07:00
co-authored by Claude
parent 1f43d7fd2e
commit 68bbe9dcae
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -548,7 +548,13 @@ inlineToOrg (Cite cs lst) = do
_ -> mempty
return $ "[cite" <> sty <> ":" <> citeItems <> "]"
else inlineListToOrg lst
inlineToOrg (Code _ str) = return $ "=" <> literal str <> "="
inlineToOrg (Code _ str) = return $
-- Org offers no escape mechanism inside verbatim text; if the
-- content contains the delimiter, fall back to the other verbatim
-- delimiter.
if "=" `T.isInfixOf` str && not ("~" `T.isInfixOf` str)
then "~" <> literal str <> "~"
else "=" <> literal str <> "="
inlineToOrg (Str str) = do
opts <- gets stOptions
let str' = if isEnabled Ext_smart opts || isEnabled Ext_special_strings opts
+1 -1
View File
@@ -598,7 +598,7 @@ Ellipses...and...and....
These shouldn't be math:
- To get the famous equation, write =$e = mc^2$=.
- To get the famous equation, write ~$e = mc^2$~.
- $22,000 is a /lot/ of money. So is $34,000. (It worked if “lot” is
emphasized.)
- Shoes ($20) and socks ($5).