Prettyprinter sections
Factor handbook > Developer tools > The prettyprinter > Extending the prettyprinter

Prev:Prettyprinting more complex literals


The prettyprinter's formatting engine can be used directly:
with-pprint ( obj quot -- )


Code in a with-pprint block or a method on pprint* can build up a tree of sections. A section is either a text node or a block which itself consists of sections.

Once the output sections have been generated, the tree of sections is traversed and intelligent decisions are made about indentation and line breaks. Finally, text is output.
section


Adding leaf sections:
line-break

text ( string -- )

styled-text ( string style -- )


Nesting and denesting sections:
<object ( obj -- )

<block ( -- )

<inset ( narrow? -- )

<flow ( -- )

<colon ( -- )

block> ( -- )


New types of sections can be defined.
Prettyprinter section protocol