diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-31 22:45:17 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-31 22:48:11 +0200 |
commit | b01f12e54ab74bbe5a923d51d5b0f4178bf7319b (patch) | |
tree | d325cc0b36f6e804a70ac616279ecce2aee7eb10 /adapter/protocol/man.nim | |
parent | b6afe9fbc9a8c4b6390a90a07b648e898b016698 (diff) | |
download | chawan-b01f12e54ab74bbe5a923d51d5b0f4178bf7319b.tar.gz |
man: fix command path manpage links
isCommand was completely broken
Diffstat (limited to 'adapter/protocol/man.nim')
-rw-r--r-- | adapter/protocol/man.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/adapter/protocol/man.nim b/adapter/protocol/man.nim index 9dfcb20e..10373efa 100644 --- a/adapter/protocol/man.nim +++ b/adapter/protocol/man.nim @@ -88,9 +88,9 @@ func processBackspace(line: string): string = if inB: s &= "</b>" return s -proc isCommand(paths: seq[string]; s: string): bool = +proc isCommand(paths: seq[string]; name, s: string): bool = for p in paths: - if fileExists(p & s): + if p & name == s: return true false @@ -195,8 +195,9 @@ proc processManpage(ofile, efile: File; header, keyword: string) = if not fileExists(target) and not symlinkExists(target) and not dirExists(target): continue - let link = if paths.isCommand(target): - "<a href='man:" & target.afterLast('/') & "'>" & s & "</a>" + let name = target.afterLast('/') + let link = if paths.isCommand(name, target): + "<a href='man:" & name & "'>" & s & "</a>" else: "<a href='file:" & target & "'>" & s & "</a>" line[cap.s..<cap.e] = link @@ -233,7 +234,7 @@ proc processManpage(ofile, efile: File; header, keyword: string) = let man = line[manCap.s..<manCap.e] # ignore footers like MYPAGE(1) # (just to be safe, we also check if it's in paths too) - if man == ignoreMan and not paths.isCommand(man): + if man == ignoreMan and not paths.isCommand(man.afterLast('/'), man): continue let cat = man & line[secCap.s..<secCap.e] let link = "<a href='man:" & cat & "'>" & man & "</a>" |