This module manages rendering answers using alternative vizualizations.
The idea is that a specific context uses zero or more rendering
modules. These rendering modules provide an alternative HTML
representation for the target term. If multiple possible renderings are
<div class="render-multi"> element is generated that
contains the alternative renderings. The jQuery plugin
answer.js adds the behaviour to change rendering to the
The user can import rendering schemes into the current context using the
directive below. Spec is either an atom or string, making the system
render(Spec), or it is a (single) file specification that can
be used for use_module/1.
A rendering module is a Prolog module that defines the non-terminal term_rendering//3, which will be called as below. Term is the (non-var) term that must be rendered, Vars is a list of variable names bound to this term and Options is a list of write options that would normally be passed to write_term/3. The grammar is executed by library(http/html_write) and must generate compatible tokens (which means it must call html//1 to generate HTML tokens).
phrase(Renderer:term_rendering(Term, Vars, Options), Tokens)
- Register an answer renderer. Same as
- use_rendering(:ID, +Options)
- Register an answer renderer with options. Options are merged with write-options and passed to the non-terminal term_rendering//3 defined in the rendering module.
- current_renderer(Name, Comment) is nondet
- True when renderer Name is declared with Comment.
- register_renderer(:Name, +Comment)
- Register a module as SWISH rendering component.