|
44 | 44 | :- use_module(library(isub), [isub/4]). |
45 | 45 | :- autoload(library(apply), [maplist/3]). |
46 | 46 | :- 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]). |
48 | 48 | :- autoload(library(pairs), [pairs_values/2]). |
49 | 49 | :- autoload(library(porter_stem), [tokenize_atom/2]). |
50 | 50 | :- autoload(library(process), [process_create/3, process_which/2]). |
|
59 | 59 | :- autoload(library(prolog_code), [pi_head/2]). |
60 | 60 | :- autoload(library(prolog_xref), [xref_source/2]). |
61 | 61 | :- use_module(library(lynx/pldoc_style), []). |
| 62 | +:- autoload(library(terms), [mapsubterms/3]). |
62 | 63 |
|
63 | 64 | /** <module> Text based manual |
64 | 65 |
|
|
171 | 172 | show_html_hook(HTML), |
172 | 173 | !. |
173 | 174 | 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), |
178 | 177 | page_width(PageWidth), |
179 | 178 | LineWidth is PageWidth - 4, |
180 | 179 | with_pager(html_text(DOM, [width(LineWidth)])). |
|
456 | 455 | sub_atom(P, _, _, _, 'ediprolog'), |
457 | 456 | !. |
458 | 457 |
|
459 | | - |
460 | 458 | %! apropos(+Query) is det. |
461 | 459 | % |
462 | 460 | % Print objects from the manual whose name or summary match with |
|
598 | 596 | close(In)), |
599 | 597 | with_output_to(string(HelpText), html_text(Dom, [])). |
600 | 598 |
|
| 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 | + |
601 | 618 | /******************************* |
602 | 619 | * MESSAGES * |
603 | 620 | *******************************/ |
|
0 commit comments