diff --git a/main/pub/src/doc/sail-moveme.md b/main/pub/src/doc/sail-moveme.md new file mode 100644 index 0000000000..af58fbd91e --- /dev/null +++ b/main/pub/src/doc/sail-moveme.md @@ -0,0 +1,472 @@ +Structures +========== + +The fundamental hoon structure used to generate XML is a manx. A manx is +composed of a `marx` and a `marl`, representing an XML node: + + +``` +++ manx ,[g=marx c=marl] :: XML node +++ marx ,[n=mane a=mart] :: XML tag +++ mane $|(@tas [@tas @tas]) :: XML name/space +``` + +Names, manes +------------ + +The most basic `manx` consists of an XML node name, called a `mane`, an empty +`marl`, and an empty `mart`: + +``` +~zod/try=> ;div +[[%div ~] ~] +~zod/try=> ;namespaced_div; +[[[%namespaced %div] ~] ~] +``` + +This represents an XML node, an opening and a closing tag with no attributes +nor children: + +``` +~zod/try=> (xmlt | ;div; "") +"
" +~zod/try=> (xmlt | ;namespaced_div; ~) +"" +``` + +**Note**: `++xmlt` takes three arguments: a loobean determening whether text should be +xml-escaped, the `manx` to be rendered, and a tape onto which to append the +results. ` +``` + +Tall form +========== + +Most development is done in tall form: + +``` +;html + ;head + ;title + ; Hi + == + == + ;body + ;p + ; Hello world + == + == +== +``` + +This produces the `manx`: + +``` +g=[n=%html a=~] + c + ~[ + [ g=[n=%head a=~] + c=~[[g=[n=%title a=~] c=~[[g=[n=%$ a=~[[n=%$ v="Hi +"]]] c=~]]]] + ] + [ g=[n=%body a=~] + c=~[[g=[n=%p a=~] c=~[[g=[n=%$ a=~[[n=%$ v="Hello world +"]]] c=~]]]] + ] + ] +] +``` + +When the `manx` is rendered, it produces: + +``` +Hi +

Hello world +

+``` + +As previously mentioned, a tag must always be closed. In tall form, this is accomplished by a `'=='`, which should align directly beneath it; any node in between the two is a subnnode. + +As demonstrated in the example above, the tall form for character data +is opened by `'; '` (note the space). Unlike wide form, the text that follows +the `'; '` is not wrapped in quotes, but is instead terminated with a new +line. The syntax for interpolation remains the same. + +The final way in which a tag may be closed is with `': '`, which is equivalent +to a `manx` with a single child declared by `'; '`. As with `'; '`, the text + declared by the `': '` is terminated by a new line: + +``` +;p: par contents +::

par contents

+``` + +Another syntax that is unique to tall form is`';='`, which describes a `marl` +with no tag: + +``` +!: +=- [- (xmll | - ~)] +;= + ;p: node + ;node(with "attribute"); +== +``` + +This produces the `marl`: + +``` +[[[%p ~] [[%~. [%~. "node"] ~] ~] ~] [[%node [%with "attribute"] ~] ~] ~] +``` + + +Notice how this renders two XML nodes without an outer tag: + +``` + "

node

" +``` + +Tall interpolation +------------------ + +A ';' followed by an interpolation glyph(`-, +, *, or %`) and two or more spaces, +accepts a twig and interpolates it into the surrounding structure: + +``` +;div#demo + ;- "foo" + ;+ ;p:"bar" + ;* :- ;p:"baz" + ?: & + ~ + ~[;hi;] + ;% |= a=marl + (weld a a) + ; dup +== +``` + +This produces the `manx`: + +``` +[ g=[n=%div a=~[[n=%id v="demo"]]] + c + ~[ + [g=[n=%$ a=~[[n=%$ v="foo"]]] c=~] + [g=[n=%p a=~] c=~[[g=[n=%$ a=~[[n=%$ v="bar"]]] c=~]]] + [g=[n=%p a=~] c=~[[g=[n=%$ a=~[[n=%$ v="baz"]]] c=~]]] + [g=[n=%$ a=~[[n=%$ v="dup +"]]] c=~] + [g=[n=%$ a=~[[n=%$ v="dup +"]]] c=~] + ] + ] +``` + +When the `manx` is rendered, it produces: + +``` +
foo

bar

baz

dup +dup +
+``` + +Attributes +---------- + +The tall form syntax for attributes is `'='` followed by a `mane` (the key), two +or more spaces, and a tall twig that produces a tape: + +``` +;div + =id "foo" + =class "bar" + ;p: baz` +== +``` + +This produces the `manx`: + +``` +[ g=[n=%div a=~[[n=%id v="foo"] [n=%class v="bar"]]] + c=~[[g=[n=%p a=~] c=~[[g=[n=%$ a=~[[n=%$ v="baz"]]] c=~]]]] +] +``` + +When rendered, this `manx` produces: + +``` +

baz

+``` + +The tall-form syntax can be combined with the wide-form attribute syntax (and all of its short forms): + +``` +;html + ;div#foo(tag "bar") + =attr "exceedingly value in here" + ; tall form + ;p: contents + == +== +``` + +This produces the `manx`: + +``` +[ [%html ~] + [ [%div [%id "foo"] [%tag "bar"] [%attr "hella long value in here"] ~] + [[%~. [%~. "tall form +"] ~] ~] + [[%p ~] [[%~. [%~. "contents"] ~] ~] ~] + ~ + ] + ~ +] +``` + +When rendered, this `manx` produces: + +``` +"
tall form +

contents

" +``` + + +