fix(primitive): normalize whitespace before pattern match in pattern and linepattern #86

Closed
opened 2026-05-26 20:37:53 +02:00 by michael · 1 comment
Owner

Problem

pattern and linepattern primitives use plain string search without
normalizing whitespace. A pattern like "version =" does not match
"version =" (two spaces), causing rules to silently produce no finding
when formatting differs from the expected pattern.

Affected primitives

  • daw.fragjan.check.pattern
  • daw.fragjan.check.linepattern

Fix

Normalize whitespace in each line before matching:
local normalized = line:gsub("%s+", " ")

Note

daw.fragjan.check.listvalues already implements this fix.

Refs DAW/fragjan#75.

## Problem pattern and linepattern primitives use plain string search without normalizing whitespace. A pattern like "version =" does not match "version =" (two spaces), causing rules to silently produce no finding when formatting differs from the expected pattern. ## Affected primitives - daw.fragjan.check.pattern - daw.fragjan.check.linepattern ## Fix Normalize whitespace in each line before matching: local normalized = line:gsub("%s+", " ") ## Note daw.fragjan.check.listvalues already implements this fix. Refs DAW/fragjan#75.
Author
Owner

Approach revised: normalize_whitespace implemented as optional parameter in listvalues (default true). pattern and linepattern should get the same optional parameter (default false) to avoid breaking existing rules.

Approach revised: normalize_whitespace implemented as optional parameter in listvalues (default true). pattern and linepattern should get the same optional parameter (default false) to avoid breaking existing rules.
michael added this to the Basic Version milestone 2026-05-30 16:04:44 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#86
No description provided.