2019-06-10

(sph web shtml)

helpers to create html as sxml

part of sph-lib

import name

(sph web shtml)

exports

procedure: shtml->html shtml port ->
write html from shtml to port, adding a <!doctype html> declaration at the beginning
procedure: shtml-alist->options a ->
((content . string:value/false)/string ...) -> sxml:((option _ ...) ...)
create the shtml for multiple <option> elements
procedure: shtml-heading depth content ... ->
integer sxml -> sxml
create a html heading element, for example <h1>, with the given content
procedure: shtml-include-css path ->
string -> sxml
create the shtml for including a stylesheet file
procedure: shtml-include-javascript path [is-async] ->
string boolean -> sxml
create the shtml for including a javascript file
variable: shtml-indent
procedure: shtml-indent-create depth ->
integer -> sxml
creates indent with the html entity for the space character so it does not get compressed by the viewer
procedure: shtml-list->list a [ordered?] ->
(sxml/list:sub-list) boolean -> sxml
create the shtml for an unordered or ordered list structure, <ul> or <ol>, with elements.
input list elements that are lists are recursively created as shtml sublists
procedure: shtml-list->table a ->
((sxml:cell ...) ...) -> sxml
create the shtml for a <table> with content
procedure: shtml-section depth title content attributes ... ->
integer sxml sxml (string/symbol string/symbol) ... -> sxml
create the sxml for an html <section> tag with attributes, heading and content in a single html tag.
content is put in a <div> unless it already is contained in single tag or if it is empty.
the single tag is ensured to make accessors for the content area (everything not first heading) simpler
procedure: shtml-text->sxml a ->
string -> sxml
replace newlines with (br)