Skip to content

Commit 0098c37

Browse files
committed
Work in progress to support manual links in Epilog.
1 parent c3e1fb0 commit 0098c37

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

library/help.pl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
:- use_module(library(isub), [isub/4]).
4545
:- autoload(library(apply), [maplist/3]).
4646
:- autoload(library(error), [must_be/2]).
47-
:- autoload(library(lists), [append/3, sum_list/2]).
47+
:- autoload(library(lists), [append/3, sum_list/2, select/3]).
4848
:- autoload(library(pairs), [pairs_values/2]).
4949
:- autoload(library(porter_stem), [tokenize_atom/2]).
5050
:- autoload(library(process), [process_create/3, process_which/2]).
@@ -59,6 +59,7 @@
5959
:- autoload(library(prolog_code), [pi_head/2]).
6060
:- autoload(library(prolog_xref), [xref_source/2]).
6161
:- use_module(library(lynx/pldoc_style), []).
62+
:- autoload(library(terms), [mapsubterms/3]).
6263

6364
/** <module> Text based manual
6465
@@ -171,10 +172,8 @@
171172
show_html_hook(HTML),
172173
!.
173174
show_html(HTML) :-
174-
setup_call_cleanup(
175-
open_string(HTML, In),
176-
load_html(stream(In), DOM, []),
177-
close(In)),
175+
load_html(string(HTML), DOM0, []),
176+
mapsubterms(man_link, DOM0, DOM),
178177
page_width(PageWidth),
179178
LineWidth is PageWidth - 4,
180179
with_pager(html_text(DOM, [width(LineWidth)])).
@@ -456,7 +455,6 @@
456455
sub_atom(P, _, _, _, 'ediprolog'),
457456
!.
458457

459-
460458
%! apropos(+Query) is det.
461459
%
462460
% Print objects from the manual whose name or summary match with
@@ -598,6 +596,25 @@
598596
close(In)),
599597
with_output_to(string(HelpText), html_text(Dom, [])).
600598

599+
600+
/*******************************
601+
* LINKS *
602+
*******************************/
603+
604+
%! man_link(+Term, -Mapped) is semidet.
605+
606+
man_link(element(a, Attrs0, Content),
607+
element(a, Attrs, Content)) :-
608+
select(href=HREF0, Attrs0, Attrs1),
609+
format(atom(HREF), 'man:~w', [HREF0]),
610+
Attrs = [href=HREF|Attrs1].
611+
612+
:- multifile epilog:tty_link_hook/1.
613+
614+
epilog:tty_link_hook(URL) :-
615+
atom_concat('man:', ManLink, URL),
616+
format(user_error, 'Open manual link to ~p~n', [ManLink]).
617+
601618
/*******************************
602619
* MESSAGES *
603620
*******************************/

0 commit comments

Comments
 (0)