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 \