Skip to content

Commit f09bbaa

Browse files
committed
fix: exclude subobject refs from required pages detection
Item:OSW<id>#OSW<subid> subobject references were incorrectly matched as standalone Item:OSW<subid> required pages. Added negative lookbehind for # to the Item regex pattern.
1 parent 8d6ec6f commit f09bbaa

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎src/osw/controller/page_package.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
group_keys=["file"],
7272
),
7373
"Item strings": RegExPatternExtended(
74-
description="Match: Item:OSW<uuid>",
75-
pattern=r"(Item:OSW[a-f0-9]{32})",
74+
description="Match: Item:OSW<uuid> but not subobject refs after #",
75+
pattern=r"(?<!#)(Item:OSW[a-f0-9]{32})",
7676
group_keys=["item"],
7777
),
7878
}

‎src/osw/utils/regex.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ def count_match_groups(pattern: Union[str, re.Pattern]):
181181
group_count += 1
182182
unmatched_brackets -= 1
183183

184-
corrected_group_count = group_count - pattern.count("(?:")
184+
# Subtract non-capturing groups and zero-width assertions
185+
non_capturing = (
186+
pattern.count("(?:")
187+
+ pattern.count("(?=")
188+
+ pattern.count("(?!")
189+
+ pattern.count("(?<=")
190+
+ pattern.count("(?<!")
191+
)
192+
corrected_group_count = group_count - non_capturing
185193
return corrected_group_count
186194

187195

0 commit comments

Comments
 (0)