The dom package

This module defines a DOM (Document Object Model) for LilyPond source files.

This LilyPond DOM is a simple tree structure where a command or environment is represented by a node with possible child nodes.

Some LilyPond commands have their own node type, and the arguments are represented by child nodes, while other commands use a generic Command node.

This DOM is used in two ways:

  1. Building a LilyPond source document from scratch. This helps to create a LilyPond document, although it in no way forces the output to be a valid LilyPond file.

  2. Transforming a parce tree of an existing LilyPond source document to a DOM document. All tokens are stored in the nodes (in the origin attributes), so it is possible to write back modifications to the original document without touching other parts of the document.

All nodes in this DOM inherit from the Element class.

Modules in the dom package: