html_text.pl -- Render HTML as plain text
This module renders HTML markup as plain text, just like the open lynx program does. It is (as yet), limited to and spacialized for dealing with the SWI-Prolog documentation. This library first of all supports help/1.
- html_text(+Input) is det
- html_text(+Input, +Options) is det
- Render HTML from Input to
current_output
. Input is either an HTML DOM or a valid input for load_html/3. Options defined are:- margin_left(+N)
- margin_right(+N)
- Initial margins.
- width(+N)
- Total preceived line width.
- text_align(+Align)
- One of
justify
orleft
. Default isjustify
.
- format_dom(+DOM, +State) is det[private]
- Format the given HTML DOM to
current_output
according to State. - block_element(+El, +Attrs, -Margin, -ParOPtions, -Style)[private]
- Describe a block element
- block_words(+Content, -RestContent, -Words, +State)[private]
- Turn Content into a list of words with attributes and spaces.
- words(+Tokens, +State)//[private]
- Generate a list of
w(Word,Len,Attrs)
andb(Len,_)
terms for words and (breakable) white space. - join_whitespace(Elements, Joined)[private]
- Join consequtive space elements into a single white space element.
- update_style(+Style:list, +State0, -State)[private]
- Add Style to the current state.
- add1_style(+New, +Style0, -Style) is det[private]
- Modify the current text style.
- state_par_properties(+State, -ParProps)[private]
- Get the paragraph shape properties from State. Eventually these two should be merged!
- emit_block(+Words, +Options, +State) is det[private]
- Format a block given Words inline elements, Options and State. Calls format_paragraph/2 after finalizing the paragraph shape and using the newline logic.
- init_nl is det[private]
- init_nl(-State) is det[private]
- exit_nl(+State) is det[private]
- Initialize/finalize the newline logic.
- emit_code(+Content, +BlockAttrs, +State)[private]
- format_table(+Content, +Attrs, +BlockAttrs, +State) is det[private]
- column_widths(+AutoWidths, +MaxTableWidth, -Widths) is det[private]
- Establish the widths of the columns. AutoWidths is a list of widths for each of the columns if no folding is applied.
- rows(+Content, -Rows) is det[private]
- columns(+Rows, -Columns) is det[private]
- Transpose the table, filling missing columns with an empty
td
element as needed. - format_row(+ColWidths, +State, +MarginLeft, +Row)[private]
- Format a single row.
- format_cells(+ColWidths, -CWSpanned, +Col0, +Row, +State, -Cells)[private]
- Format the cells for Row. The resulting Cells list is a list of cells, where each cell is a list of strings, each representing a line.
- cell_align(+Cell, -Align) is det[private]
- Determine the cell alignment. Currently supports the (deprecated)
HTML4
align=Align
possibility and very naively parsed CSStext-align:center
, etc. - format_cell_to_string(+Cell, +ColWidth, +State, -String) is det[private]
- Format Cell to a String, given the state and column width.
- emit_hr(+Attrs, +BlockOptions, +State)[private]
- Emit a horizontal rule.
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
- html_text(+Input) is det
- html_text(+Input, +Options) is det
- Render HTML from Input to
current_output
. Input is either an HTML DOM or a valid input for load_html/3. Options defined are:- margin_left(+N)
- margin_right(+N)
- Initial margins.
- width(+N)
- Total preceived line width.
- text_align(+Align)
- One of
justify
orleft
. Default isjustify
.