HTML Rendering

It's possible to specify OBO-Edit renderers in HTML code. Most renderers are implemented in this way behind the scenes, but users can also specify their own HTML code directly. HTML can be used in any renderer (e.g. in a global renderer or a component such as an Ontology Tree Editor or Graph Editor panel), and some components allow you to specify an HTML expression to display terms.

Search criteria

HTML rendering uses search criterion IDs to refer to terms or to specific pieces of information about a term. Commonly used search criterion IDs include $name$ and $id$, referring to the term name and ID respectively, and $term$, which refers to any term that matches a renderer's search criteria. See "Technical Aspects of HTML Rendering" below for more information on search criteria (note: some of the information on criteria is aimed at programmers more than end users).

HTML Expressions

HTML expressions allow you to specify what information is shown for each term in a panel. In the Ontology Tree Editor or Graph Editor, click the configuration wrench icon, then click the "HTML Expression" tab to bring up a box in which you can type or paste an expression; in the Graph Viewer, the box is visible immediately when you click the configuration icon.

This example is included in the HTML Expression configuration screens; it places the ID on the line below the term name, in italics:

The resulting Graph Viewer display:

HTML Code in Renderers

You can use the "HTML Code" checkbox on any term renderer configuration screen to add HTML to specify a rendering effect. Usually, you will use $term$ along with some HTML markup to change the appearance of terms that match the filter criteria (also see "Technical Aspects of HTML Rendering" below).

In addition to specifying text effects (such as thtose available using checkboxes), an HTML renderer can be used to prepend or append text to a selected set of terms. For example, this search finds all terms with the dbxref "GOC:mtg_cardio":

These renderer settings make the text blue and boldface, and prepend the text "cardio term:" to the names of all terms with this dbxref:

Note that the 'HTML Code' checkbox is checked, and the text "cardio term: $term$" is entered in the box. The text "$term$" shows where the name of the term will be, relative to the added text.

To append text, insert "$term$: cardio term" in the box instead.

Once the renderer is set up correctly, click 'Save Changes' and then search for the terms as shown above.

When you click on any of the search results, the term name will appear in the rendered panel with the text prepended. If the renderer is set up in the Global Filters component, the prepended text will also be visible in the search results tab:

The text is not prepended in the Text Editor Panel, even if a global renderer is used:

Technical Aspects of HTML Rendering

The HTML code used by the rendering system is standard HTML, with the addition of some special purpose expressions. These expressions are always enclosed between $ characters (e.g. $name$), and are of two types:

Search Criterion IDs

Any renderer specification can include a search criterion identifier, enclosed in $ characters. The available search criteria ids in any OBO-Edit session can be discovered with the code:

for(SearchCriterion<?> crit : FilterManager.getManager().getCriteria()) {
    System.out.println(crit.getID());
}

The search criterion id may be provided on its own (e.g. $name$), or it may include parameters in parentheses (e.g. $synonym(<li><i>no_synonyms</i>, *, <li>$item$)$). Search criteria may have up to three parameters, explained below. If any parameter is omitted, its default value is automatically used.

Parameters
  1. Default value - The text to display if there are no values for this search criterion, or if an out-of-range index is given for the second parameter. The default value for this parameter is an empty string.
  2. Value index- The index of the value to use if this search criterion returns multiple values. If the value of this parameter is *, all the values are used and displayed according to the formatting specified in the third parameter. The default value for this parameter is 0.
  3. Repeated value expression - Another html expression used to format multi-valued search criteria. This expression will be repeated for each value of the given search criterion. In this expression, the variable $item$ will be replaced with the current search criterion value.

Results from other renderers

A term may match several HTML renderers, so most HTML renderers will be written to wrap HTML data generated by some other renderer with additional HTML. The output from any nested renderers is wrapped in the $term$ variable. So, for example, the following renderer expression would take the result of any previous renderers and append the word "obsolete" in italics after it:

$term$ <i>(obsolete)</i>

HTML Expression Format

As noted above, the Ontology Editor Panel, Graph Editor, and Global Filter Manager allow users to specify an "HTML Expression" - the basic html expression used as the starting value for all other renderers. This expression uses the exact same syntax as the renderer expressions described above, except that the $term$ variable is not available, because there are no previous renderer values to access.