cssgrep 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.8.0] - 2026-07-13
11
+
12
+ ### Changed
13
+ - The `-n` locator is now colon-separated from the text —
14
+ `file:line:col:text` instead of `file:line:col text` — matching grep's
15
+ separator and making the output byte-compatible with `rg --vimgrep`. Vim
16
+ users can use the standard `grepformat=%f:%l:%c:%m` (docs updated); scripts
17
+ parsing the old space-separated form need the one-character change.
18
+
10
19
  ## [1.7.0] - 2026-07-12
11
20
 
12
21
  ### Added
@@ -152,7 +161,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
152
161
  - `-0`/`--null`, `--color`, `-w`/`--max-width`, `-V`/`--version`.
153
162
  - Standalone binaries (Bun, Node SEA), shell completions, and a man page.
154
163
 
155
- [Unreleased]: https://github.com/msbatarce/cssgrep/compare/v1.7.0...HEAD
164
+ [Unreleased]: https://github.com/msbatarce/cssgrep/compare/v1.8.0...HEAD
165
+ [1.8.0]: https://github.com/msbatarce/cssgrep/compare/v1.7.0...v1.8.0
156
166
  [1.7.0]: https://github.com/msbatarce/cssgrep/compare/v1.6.0...v1.7.0
157
167
  [1.6.0]: https://github.com/msbatarce/cssgrep/compare/v1.5.0...v1.6.0
158
168
  [1.5.0]: https://github.com/msbatarce/cssgrep/compare/v1.4.0...v1.5.0
package/README.md CHANGED
@@ -63,14 +63,15 @@ cat page.html | cssgrep <selector> # read from stdin
63
63
 
64
64
  Like `grep`, each matching line is printed on its own, once — however many
65
65
  matches sit on it. With `-n` there is one record *per match*, each with its
66
- own `line:col` locator (that per-match precision is the point of the tool). A
66
+ own `line:col` locator (that per-match precision is the point of the tool),
67
+ colon-separated from the text — byte-compatible with `rg --vimgrep`. A
67
68
  `file:` prefix is added when searching multiple files:
68
69
 
69
70
  ```
70
71
  {line contents} # default; stdin or single file
71
72
  {file}:{line contents} # default; multiple files
72
- {line}:{col} {line contents} # -n; stdin or single file
73
- {file}:{line}:{col} {line contents} # -n; multiple files
73
+ {line}:{col}:{line contents} # -n; stdin or single file
74
+ {file}:{line}:{col}:{line contents} # -n; multiple files
74
75
  ```
75
76
 
76
77
  ### Options
@@ -324,12 +325,13 @@ message pointing back to these recipes, rather than a bare "unknown option".
324
325
 
325
326
  ## Vim / Neovim integration
326
327
 
327
- The `file:line:col text` format produced by `-n` is `:grep`-compatible. Point
328
+ The `file:line:col:text` format produced by `-n` is byte-compatible with
329
+ `rg --vimgrep`, so the standard ripgrep `grepformat` works as-is. Point
328
330
  `grepprg` at `cssgrep -n -r` and hits land in the quickfix list:
329
331
 
330
332
  ```vim
331
333
  set grepprg=cssgrep\ -n\ -r
332
- set grepformat=%f:%l:%c\ %m
334
+ set grepformat=%f:%l:%c:%m
333
335
 
334
336
  " :grep 'div.card' src/ then :copen
335
337
  ```
package/cli.js CHANGED
@@ -29,7 +29,7 @@ function loadPrettyPrinter() {
29
29
  // package.json, so it survives compilation into a standalone binary (Bun
30
30
  // --compile / Node SEA), where package.json won't sit next to the executable.
31
31
  // Keep in sync with package.json on release.
32
- const VERSION = '1.7.0';
32
+ const VERSION = '1.8.0';
33
33
 
34
34
  const USAGE = `cssgrep - search HTML by CSS selector, grep-style.
35
35
 
@@ -39,11 +39,12 @@ Usage:
39
39
  cssgrep -e '[label=]<sel>' [-e ...] [file ...]
40
40
  cat file.html | cssgrep <selector>
41
41
 
42
- Output (each matching line once, like grep; with -n, one record per match):
42
+ Output (each matching line once, like grep; with -n, one record per match,
43
+ byte-compatible with rg --vimgrep):
43
44
  {line contents} (default; stdin or single file)
44
45
  {file}:{line contents} (default; multiple files)
45
- {line}:{col} {line contents} (with -n; stdin or single file)
46
- {file}:{line}:{col} {line contents} (with -n; multiple files)
46
+ {line}:{col}:{line contents} (with -n; stdin or single file)
47
+ {file}:{line}:{col}:{line contents} (with -n; multiple files)
47
48
 
48
49
  Options:
49
50
  -e, --selector <[label=]sel> Add a selector (repeatable). Matches from all
@@ -647,7 +648,7 @@ function emitContext(src, starts, name, showLabel, targets, opts, out) {
647
648
  if (label) prefix += c(COLORS.file, label) + (opts.nul ? '\0' : sepColored);
648
649
  if (opts.lineNumber) {
649
650
  prefix += c(COLORS.line, String(L));
650
- prefix += m ? c(COLORS.sep, ':') + c(COLORS.line, String(m.pos.bcol)) + ' '
651
+ prefix += m ? c(COLORS.sep, ':') + c(COLORS.line, String(m.pos.bcol)) + c(COLORS.sep, ':')
651
652
  : c(COLORS.sep, '-');
652
653
  }
653
654
  const tag = m && m.selLabel != null ? c(COLORS.label, `[${m.selLabel}]`) + ' ' : '';
@@ -821,8 +822,8 @@ function searchSource(src, name, showLabel, opts, out, limit = Infinity, embedde
821
822
  text = renderText(pos, off, nodeEnd, opts);
822
823
  }
823
824
  // grep-style: a `file:` prefix appears with multiple files; the line:col
824
- // locator only with -n. The locator is separated from the text by a space
825
- // so the output stays :grep-compatible (grepformat %f:%l:%c %m).
825
+ // locator only with -n, colon-separated from the text byte-compatible
826
+ // with `rg --vimgrep` (grepformat %f:%l:%c:%m).
826
827
  const sep = c(COLORS.sep, ':');
827
828
  // -0/--null: the char after the file name becomes NUL (grep -Z), for
828
829
  // unambiguous machine parsing (e.g. xargs -0).
@@ -830,7 +831,7 @@ function searchSource(src, name, showLabel, opts, out, limit = Infinity, embedde
830
831
  let prefix = '';
831
832
  if (label) prefix += c(COLORS.file, label) + fileSep;
832
833
  if (opts.lineNumber) {
833
- prefix += c(COLORS.line, String(pos.line)) + sep + c(COLORS.line, String(pos.bcol)) + ' ';
834
+ prefix += c(COLORS.line, String(pos.line)) + sep + c(COLORS.line, String(pos.bcol)) + sep;
834
835
  }
835
836
  out.push(prefix + tag + text);
836
837
  emitted++;
package/man/cssgrep.1 CHANGED
@@ -1,6 +1,6 @@
1
1
  .\" Man page for cssgrep. Keep the OPTIONS section in sync with the USAGE
2
2
  .\" string in cli.js.
3
- .TH CSSGREP 1 "2026-07-12" "cssgrep 1.7.0" "User Commands"
3
+ .TH CSSGREP 1 "2026-07-13" "cssgrep 1.8.0" "User Commands"
4
4
  .SH NAME
5
5
  cssgrep \- search HTML by CSS selector, grep-style
6
6
  .SH SYNOPSIS
@@ -443,7 +443,7 @@ locator:
443
443
  .RS
444
444
  .nf
445
445
  set grepprg=cssgrep\e \-n\e \-r
446
- set grepformat=%f:%l:%c\e %m
446
+ set grepformat=%f:%l:%c:%m
447
447
  .fi
448
448
  .RE
449
449
  .SH SEE ALSO
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cssgrep",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Search HTML by CSS selector and print matches grep-style (file:line:col with -n).",
5
5
  "main": "lib.js",
6
6
  "types": "index.d.ts",