Next: , Previous: , Up: Concrete ostream subclasses without styling   [Contents][Index]


3.5.3.4 The html_ostream class

The html_ostream class supports output to any destination, in HTML syntax. Its type is ‘html_ostream_t’. It is a subclass of ‘ostream_t’.

It can be instantiated through this function:

Function: html_ostream_t html_ostream_create (ostream_t destination)

Creates an output stream that takes input in the UTF-8 encoding and writes it in HTML form on destination.

This stream produces a sequence of lines. The caller is responsible for opening the <body><html> elements before and for closing them after the use of this stream.

Note: The resulting stream must be closed before destination can be closed.

The class adds the following methods:

Function: void html_ostream_begin_span (html_ostream_t stream, const char *classname)

Starts a <span class="classname"> element. The classname is the name of a CSS class. It can be chosen arbitrarily and customized through the CSS file.

Function: void html_ostream_end_span (html_ostream_t stream, const char *classname)

Ends a <span class="classname"> element.

The html_ostream_begin_span / html_ostream_end_span calls must match properly.

Returns the referred URL of the currently set hyperlink, or NULL if no hyperlink attribute is currently set.

Note: The returned string is only valid up to the next invocation of html_ostream_set_hyperlink_ref.

Sets or removes a hyperlink attribute.

To set a hyperlink attribute, pass a non-NULL ref. ref is an URL; it should be at most 2083 bytes long. Non-ASCII characters should be URI-escaped (using the %nn syntax).

To remove a hyperlink attribute, pass NULL for ref.

Hyperlinks don’t nest. That is, a hyperlink attribute is enabled only up to the next invocation of html_ostream_set_hyperlink_ref.

Function: void html_ostream_flush_to_current_style (html_ostream_t stream)

This function acts like ostream_flush (stream, FLUSH_THIS_STREAM), except that it leaves the destination with the current text style enabled, instead of with the default text style.

After calling this function, you can output strings without newlines(!) to the underlying stream, and they will be rendered like strings passed to ostream_write_mem, ostream_write_str, or ostream_printf.


Next: The memory_ostream class, Previous: The term_ostream class, Up: Concrete ostream subclasses without styling   [Contents][Index]