fix(config_help): use --pattern for section jump; correct ov nav keys
--jump-target does not work reliably on piped stdin. Replace with --pattern which positions ov at the first occurrence of the keyword (works like less +/pattern) and keeps the match highlighted so the user can press n/N to navigate further occurrences. Also correct the section navigation keys in the offline manual: Space = next section (not '.') ^ = previous section (not ',') Alt+u = section list sidebar
This commit is contained in:
+10
-1
@@ -1216,7 +1216,16 @@ calls fisher update as its first step.
|
|||||||
config_help
|
config_help
|
||||||
|
|
||||||
ov renders the Markdown with syntax highlighting and section-based
|
ov renders the Markdown with syntax highlighting and section-based
|
||||||
navigation. Use , and . to jump between sections. Press / to search.
|
navigation.
|
||||||
|
|
||||||
|
Space next section
|
||||||
|
^ previous section
|
||||||
|
Alt+u toggle section list sidebar
|
||||||
|
/ search forward
|
||||||
|
n / N next / previous search match
|
||||||
|
g go to line number
|
||||||
|
j interactive jump target (line, %, or 'section')
|
||||||
|
q quit
|
||||||
|
|
||||||
## With bat
|
## With bat
|
||||||
|
|
||||||
|
|||||||
+20
-12
@@ -47,23 +47,31 @@ function config_help --description 'Open the offline fish shell configuration ma
|
|||||||
end
|
end
|
||||||
|
|
||||||
# ── Viewer fallback chain ────────────────────────────────────
|
# ── Viewer fallback chain ────────────────────────────────────
|
||||||
# Best case: bat colors the output; ov matches headers in the ANSI stream
|
# bat colors the output; ov matches headers via an ANSI-aware regex.
|
||||||
# via a regex that skips the escape codes preceding each '#'.
|
# bat emits: ESC[<color>m# ... so delimiter ^(\x1b\[[0-9;]*m)+# matches
|
||||||
# bat emits headers as: ESC[<color>m# ... so we match ^(ESC\[[0-9;]*m)+#
|
# any 8/24-bit color sequence before a '#', theme-agnostic.
|
||||||
# This is theme-agnostic (works for any 8/24-bit color sequence) and
|
# Section nav: Space (next), ^ (previous), Alt+u (section list sidebar).
|
||||||
# gives us both syntax highlighting AND section navigation (,/.).
|
# Keyword jump uses --pattern which positions at the first search match.
|
||||||
if type -q ov; and type -q bat
|
if type -q ov; and type -q bat
|
||||||
|
set -l ov_args \
|
||||||
|
--section-delimiter "^(\x1b\[[0-9;]*m)+#" \
|
||||||
|
--section-header
|
||||||
|
if test -n "$argv[1]"
|
||||||
|
set -a ov_args --pattern "$argv[1]"
|
||||||
|
end
|
||||||
bat --color=always --style=plain --language=markdown "$doc_file" \
|
bat --color=always --style=plain --language=markdown "$doc_file" \
|
||||||
| ov --section-delimiter "^(\x1b\[[0-9;]*m)+#" \
|
| ov $ov_args
|
||||||
--section-header \
|
|
||||||
--jump-target "$start_line"
|
|
||||||
|
|
||||||
# ov alone: section navigation on raw Markdown; 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 "^#" \
|
set -l ov_args \
|
||||||
--section-header \
|
--section-delimiter "^#" \
|
||||||
--jump-target "$start_line" \
|
--section-header \
|
||||||
"$doc_file"
|
"$doc_file"
|
||||||
|
if test -n "$argv[1]"
|
||||||
|
set -a ov_args --pattern "$argv[1]"
|
||||||
|
end
|
||||||
|
ov $ov_args
|
||||||
|
|
||||||
# bat alone: syntax highlighting with built-in paging; no line jump.
|
# bat alone: syntax highlighting with built-in paging; no line jump.
|
||||||
else if type -q bat
|
else if type -q bat
|
||||||
|
|||||||
Reference in New Issue
Block a user