Skip to content

Commit 1cc7b0d

Browse files
Merge pull request #435 from ossf/refine_preprocessing
Refine preprocessing
2 parents fb53e92 + 5d53e4c commit 1cc7b0d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/labs/checker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ let preprocessRegexes = [
4141
[/[ \t]+\\s\+[ \t]+/g, '\\s+'],
4242

4343
// 1+ spaces/tabs are instead interpreted as \s* (0+ whitespace)
44-
// The (\\s\*)? expressions before and after it are an optimization -
44+
// The (?:\\s\*)? expressions before and after it are an optimization -
4545
// if you use \s* next to spaces/tabs, they coalesce for speed.
46-
[/(\\s\*)?[ \t]+(\\s\*)?/g, '\\s*']
46+
// We use non-capturing groups (?:...) for speed. Preprocessing is only
47+
// done once on startup, so speed isn't important, but it's often good
48+
// to avoid capturing groups when you don't need to.
49+
[/(?:\\s\*)?[ \t]+(?:\\s\*)?/g, '\\s*']
4750
];
4851

4952
/**

docs/labs/create_checker.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,5 +608,8 @@ in this example:
608608
The optional expressions before and after it are an optimization,
609609
to coalesce this for speed.
610610

611+
In the preprocessing replacement text, you can use `$` followed by a digit
612+
to refer to the corresponding capturing group.
613+
611614
If you load `hello.html` you'll automatically run some self-tests on
612615
the default preprocessor.

0 commit comments

Comments
 (0)