From 1a752c4c876c750621721372ed3bf4868b39cbde Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 6 Jun 2026 03:24:11 -0400 Subject: [PATCH] fix(config_help): use ANSI-aware section delimiter for bat+ov pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bat emits Markdown headers as ESC[m# so the raw ^# regex never matches. Use ^(\x1b\[[0-9;]*m)+# instead — matches one or more ANSI escape sequences before the # regardless of theme or color depth. Restores section navigation (,/.) while keeping bat syntax highlighting. --- functions/config_help.fish | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/functions/config_help.fish b/functions/config_help.fish index 6bdbdf2..093b7a3 100644 --- a/functions/config_help.fish +++ b/functions/config_help.fish @@ -47,14 +47,18 @@ function config_help --description 'Open the offline fish shell configuration ma end # ── Viewer fallback chain ──────────────────────────────────── - # Best case: bat provides syntax color, ov provides paging + line jump. - # Section nav (,/.) is sacrificed when piping bat output because ANSI - # escape codes prevent ^# matching; use / to search instead. + # Best case: bat colors the output; ov matches headers in the ANSI stream + # via a regex that skips the escape codes preceding each '#'. + # bat emits headers as: ESC[m# ... so we match ^(ESC\[[0-9;]*m)+# + # This is theme-agnostic (works for any 8/24-bit color sequence) and + # gives us both syntax highlighting AND section navigation (,/.). if type -q ov; and type -q bat bat --color=always --style=plain --language=markdown "$doc_file" \ - | ov --jump-target "$start_line" + | ov --section-delimiter "^(\x1b\[[0-9;]*m)+#" \ + --section-header \ + --jump-target "$start_line" - # ov alone: full section navigation with ,/. keys; no code highlighting. + # ov alone: section navigation on raw Markdown; no code highlighting. else if type -q ov ov --section-delimiter "^#" \ --section-header \