Section "markup"

A Prolog system maintains a state through their input, output and error streams. In the case of a browser environment the corresponding output and error streams point to DOM elements, which can be simultaneously set via set_cursor(). There are also factory predicates in library(markup) to create more such markup streams.

Markup streams act on their cursor elem as defined in library(markup):

Prolog JavaScript
write('foo < bar') elem.insertAdjacentText("beforeend", "foo < bar")
tag('&amp;') elem.insertAdjacentHTML("beforeend", "&amp;")
tag('<foo>') elem.insertAdjacentHTML("beforeend", "<foo></foo>");
elem = elem.lastElementChild
tag('</foo>') elem = elem.parentElement
tag('<foo/>') elem.insertAdjacentHTML("beforeend", "</foo>")

Further DOM actions are currently found in library(react):

Prolog JavaScript
clear elem.innerHTML = ""
goto('k7') elem = document.getElementById("k7")
bind('click', E, foo(E)) elem.addEventListener("click", [E]>>foo(E))
listen('click', E, foo(E),
      [block(true)])
let prom = waitForEvent(elem, "click", [E]>>foo(E))
await prom

Kommentare