package tyxml-syntax

  1. Overview
  2. Docs

Module Tyxml_syntax.Element_contentSource

Element child argument assemblers. These are almost parsers, except they only tell how to pass already-parsed children to element functions.

Sourcetype assembler = lang:Common.lang -> loc:Ppxlib.Location.t -> name:string -> Ppxlib.expression Common.value list -> (Ppxlib.arg_label * Ppxlib.expression) list

Assemblers satisfy: assembler ~lang ~loc ~name children evaluates to a list of optionally-labeled parse trees for passing children to the the element function for element name. For example, for a table element

<table>
  <thead>
    <tr><th>A</th><th>B</th></tr>
  </thead>
  <tbody>
  </tbody>
</table>

The assembler table, when called with the parsed children, will evaluate to parse trees representing

~thead:(* the thead element *) [(* the tbody element *)]

This satisfies the child arguments in the signature of Html_sigs.T.tablex. The ~table label is represented by the string "table", and the unlabeled list argument is paired with the empty string.

The argument implementation is the name of the module providing the run-time implementation of the element function that will be applied to the children. It is either Html or Svg, and is based on the element's namespace. It is used for wrapping child elements, and for scoping child txt elements.

The name argument is used for error reporting.

Generic

Sourceval nullary : assembler
Sourceval unary : assembler
Sourceval star : assembler

Special-cased

Sourceval html : assembler
Sourceval head : assembler
Sourceval figure : assembler
Sourceval object_ : assembler
Sourceval audio_video : assembler
Sourceval table : assembler
Sourceval fieldset : assembler
Sourceval datalist : assembler
Sourceval details : assembler
Sourceval menu : assembler
Sourceval picture : assembler
Sourceval script : assembler

Misc utilities

Sourceval filter_surrounding_whitespace : Ppxlib.expression Common.value list -> Ppxlib.expression Common.value list

Remove txt node containing only whitespace that are at the beginning or the end of the list.

Sourceval comp_filter_whitespace : assembler -> assembler

Improve an assembler by removing txt nodes containing only whitespace