Surface.Formatter.Phases.Indent (surface v0.7.0) View Source

Adds indentation nodes (:indent and :indent_one_less) where appropriate.

Surface.Formatter.Render.node/2 is responsible for adding the appropriate level of indentation. It keeps track of the indentation level based on how "nested" a node is. While running Formatter Phases, it's not necessary to keep track of that detail.

:indent_one_less exists to notate the indentation that should occur before a closing tag, which is one less than its children.

Relies on Newlines phase, which collapses :newline nodes to at most 2 in a row.

Link to this section Summary

Link to this section Functions

Link to this function

add_indentation(nodes, accumulated \\ [])

View Source

Callback implementation for Surface.Formatter.Phase.run/2.