From e69c9aac245d9f01ee9ec30b39f0d9ca1e158e74 Mon Sep 17 00:00:00 2001 From: James Yu Date: Sun, 18 Aug 2024 18:30:15 +0800 Subject: [PATCH] Fix #4339 Handle cwl package option in format `#keyvals:\geometry,\usepackage/geometry#c` --- dev/pyintel/pkgcommand.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev/pyintel/pkgcommand.py b/dev/pyintel/pkgcommand.py index 3d24f0a70..8f367324f 100644 --- a/dev/pyintel/pkgcommand.py +++ b/dev/pyintel/pkgcommand.py @@ -333,6 +333,13 @@ def parse_cwl_file(self, file_path: Union[Path, str], remove_spaces: bool = Fals pkg.envs[pkgenv].keyvalpos = len(re.findall(r'\[\]|\(\)|<>|{}', re.sub(r'\${.*?}', '', pkg.envs[pkgenv].snippet[:haskeyvals.start()]))) pkg.envs[pkgenv].keyvalindex = pkg.envs[pkgenv].keyvalindex or [] pkg.envs[pkgenv].keyvalindex.append(match[1]) + elif envcmd.startswith('\\usepackage/'): + for i in range(len(re.findall(r'%<([^%]*?)%>', line))): + line = re.sub(r'%<([^%]*?)%>', '${' + str(i + 1) + r':\1}', line, 1) + match = re.match(r'^([^#%\n]*)', line) + if match is None: + continue + pkg.options.append(match[1]) else: cmd = re.match(r'\\?([^{\[#]*)', envcmd)[1] for pkgcmd in pkg.macros: