Norm Helpers

Normalizers are created with the particulars for any given document format captured in on-page Code items that are collected and installed as a module.

digraph { rankdir=LR node [shape=box style=filled fillcolor=bisque] html -> normalize -> import docs -> normalize -> download { rank=same page -> normalize normalize -> norm normalize -> script -> norm } }

A page is configured to run normalize-edits.html in a Frame plugin. This application finds and loads script fragments from Code items as a module to customize the document normalization process. github

The scripts export two functions used to traverse the chosen document which will have been already loaded into off-screen DOM memory.

export const titles = () => { ... } export const items = (title) => { ... }

The scripts import the norm.js module which manages the off-screen DOM and offers helper functions proven useful for finding and formatting titles and items. github

div = { ... } setdiv = (newdiv) => { ... }

Read and update the off-screen DOM.

select = (selector) => { ... } selectAll = (selector) => [ ... ]

Query the off-screen DOM with querySelector and querySelectorAll returning a element or an array.

frequent = (selector, nextselector) => { ... }

Find the most frequently used class for selected elements, optionally further selected with the selected element.

more = (elem) => () => { ... } repeat = (cursor) => [ ... ]

Create a cursor over element siblings returning <p> items. Repeatedly apply and collect a cursor's non-null returns.

item = (elem) => { ... }

Create a wiki story item to represent an element, typically a <p>. Attach an id constructed from a few long words that are likely to match across document types.

Create new normalizers from the Normalize Template.