2020-05-13 00:08:53 +03:00
|
|
|
^? |%
|
|
|
|
::
|
2020-05-13 02:12:43 +03:00
|
|
|
+$ tile :: XX: ?@(knot (pair styl knot))
|
|
|
|
::
|
|
|
|
cord
|
|
|
|
::
|
2020-05-13 00:08:53 +03:00
|
|
|
:: A `plum` is the intermediate representation for the pretty-printer. It
|
|
|
|
:: encodes hoon-shaped data with the least amount of structured needed
|
|
|
|
:: for formating.
|
|
|
|
::
|
|
|
|
:: A `plum` is either a
|
|
|
|
::
|
|
|
|
:: - `cord`: A simple cord
|
|
|
|
:: - `[%para *]`: A wrappable paragraph.
|
|
|
|
:: - `[%tree *]`: A formatted plum tree
|
|
|
|
:: - `[%sbrk *]`: An indication of a nested subexpression.
|
|
|
|
::
|
|
|
|
:: The formatter will use the tall mode unless:
|
|
|
|
::
|
|
|
|
:: - A plum has only a `wide` style.
|
|
|
|
:: - The plum is in `%sbrk` form and its subplum (`kid`), when
|
|
|
|
:: formatted in wide mode, can fit on a single line.
|
|
|
|
::
|
|
|
|
+$ plum
|
|
|
|
$@ cord
|
|
|
|
$% [%para prefix=tile lines=(list @t)]
|
|
|
|
[%tree fmt=plumfmt kids=(list plum)]
|
|
|
|
[%sbrk kid=plum]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: A `plumfmt` is a description of how to render a `plum`. A `plumfmt`
|
|
|
|
:: must include a `wide`, a `tall`, or both.
|
|
|
|
::
|
|
|
|
:: A `wide` is a description of how to render a plum in a single
|
|
|
|
:: line. The nested (`kids`) sub-plums will be interleaved with `delimit`
|
|
|
|
:: strings, and, if `enclose` is set, then the output will be enclosed
|
2020-11-24 10:15:12 +03:00
|
|
|
:: with `p.u.enclose` and `q.u.enclose`.
|
2020-05-13 00:08:53 +03:00
|
|
|
::
|
|
|
|
:: For example, to build a plumfmt for string literals, we could write:
|
|
|
|
::
|
|
|
|
:: [wide=[~ '' [~ '"' '"']] tall=~]
|
|
|
|
::
|
|
|
|
:: A `tall` is a description of how to render a plum across multiple
|
|
|
|
:: lines. The output will be prefixed by `intro`, suffixed by
|
|
|
|
:: `final.u.indef`, and each subplum prefixed by `sigil.u.indef`.
|
|
|
|
::
|
|
|
|
:: For example, to build a plumfmt for cores, we could write:
|
|
|
|
::
|
|
|
|
:: [wide=~ tall=`['' `['++' '--']]]
|
|
|
|
::
|
|
|
|
+$ plumfmt
|
|
|
|
$: wide=(unit [delimit=tile enclose=(unit (pair tile tile))])
|
|
|
|
tall=(unit [intro=tile indef=(unit [sigil=tile final=tile])])
|
|
|
|
==
|
|
|
|
--
|