Utility functions for managing text fragments and friends.
namespace text utilities
import ideal • machine • channels • string writer
boolean is block(text element element)
return is indent(element) || id == text library • HTML || id == text library • HEAD || id == text library • BODY || id == text library • TITLE || id == text library • META || id == text library • LINK || id == text library • P || id == text library • DIV || id == text library • H1 || id == text library • H2 || id == text library • TABLE || id == text library • TR || id == text library • TH || id == text library • TD || id == text library • BR
immutable list[text node] to list(text fragment or null fragment)
if fragment is null
else if fragment is text node
else if fragment is list text node
else
return make singleton(fragment)
return fragment • nodes
overload text fragment join(readonly list[text fragment] fragments)
overload text fragment join(text fragment first, text fragment second, text fragment third, text fragment fourth)
attribute fragment join attributes(readonly list[attribute fragment] fragments)
if fragments • size == 1
for (fragment : fragments)
return fragments • first
return base list attribute fragment • new(result fragments)
private void append(list[text node] nodes, text fragment fragment)
private text fragment to fragment(readonly list[text node] nodes)
if nodes • is empty
else if nodes • size == 1
else
return EMPTY FRAGMENT
return nodes • first
return base list text node • new(nodes)
string to plain text(text fragment text)
the writer : string writer • new()
return the writer • elements()
string to markup string(text fragment text)
the writer : string writer • new()
return the writer • elements()
text element make element(element id id, readonly list[text node] children)
if children is_not null
else
return base element • new(id, list dictionary[attribute id, attribute fragment] • new(), child fragment)