LaTeX writer: don't unpack code string to choose lstinline delimiter.

Scan the Text directly for each candidate delimiter (with early
exit) instead of unpacking the whole string and using list
difference.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-20 18:41:15 +00:00
co-authored by Claude
parent 3554ed71a3
commit 135992dbd0
+4 -4
View File
@@ -33,7 +33,7 @@ import Control.Monad
import Crypto.Hash (hashWith, MD5(MD5))
import Data.Containers.ListUtils (nubOrd)
import Data.Char (isDigit, isAscii, isLetter)
import Data.List (intersperse, partition, (\\))
import Data.List (find, intersperse, partition)
import qualified Data.Set as Set
import Data.Maybe (catMaybes, fromMaybe, isJust, listToMaybe, mapMaybe, isNothing)
import Data.Monoid (Any (..))
@@ -990,9 +990,9 @@ inlineToLaTeX (Code (_,classes,kvs) str) = do
listingsopts) <> "]"
inNote <- gets stInNote
when inNote $ modify $ \s -> s{ stVerbInNote = True }
let chr = case "!\"'()*,-./:;?@" \\ T.unpack str of
(c:_) -> c
[] -> '!'
let chr = fromMaybe '!' $
find (\c -> not (T.any (== c) str))
("!\"'()*,-./:;?@" :: String)
let isEscapable '\\' = True
isEscapable '{' = True
isEscapable '}' = True