fix(config_help): use ANSI-aware section delimiter for bat+ov pipeline
bat emits Markdown headers as ESC[<color>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.
This commit is contained in:
@@ -47,14 +47,18 @@ function config_help --description 'Open the offline fish shell configuration ma
|
|||||||
end
|
end
|
||||||
|
|
||||||
# ── Viewer fallback chain ────────────────────────────────────
|
# ── Viewer fallback chain ────────────────────────────────────
|
||||||
# Best case: bat provides syntax color, ov provides paging + line jump.
|
# Best case: bat colors the output; ov matches headers in the ANSI stream
|
||||||
# Section nav (,/.) is sacrificed when piping bat output because ANSI
|
# via a regex that skips the escape codes preceding each '#'.
|
||||||
# escape codes prevent ^# matching; use / to search instead.
|
# bat emits headers as: ESC[<color>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
|
if type -q ov; and type -q bat
|
||||||
bat --color=always --style=plain --language=markdown "$doc_file" \
|
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
|
else if type -q ov
|
||||||
ov --section-delimiter "^#" \
|
ov --section-delimiter "^#" \
|
||||||
--section-header \
|
--section-header \
|
||||||
|
|||||||
Reference in New Issue
Block a user