CommonDoc ยป Nodes

A node is a subtree of a document. Nodes range from atomic nodes like text nodes and images to containing nodes like paragraphs, bold text nodes, or section nodes.


Create a metadata table from a list of pairs. If the list is empty, return an empty metadata table.
get-meta(node key)
Find the value corresponding to key in the node's metadata. If not found, return NIL.
do-meta((key value node) &body body)
Iterate over the keys and values of a node's metadata.

Basic Classes


A document.

Metadata is mostly based on Dublin Core and the OpenDocument format.

  • children
    The document's children nodes.
  • title
    The document's title.
  • creator
    The creator of the document.
  • publisher
    The document's publisher.
  • subject
    The subject the document deals with.
  • description
    A description of the document.
  • keywords
    A list of strings, each being a keyword for the document.
  • reference
    A reference string to uniquely identify the document within a certain context.
  • language
    An RFC4646 string denoting the language the document is written in.
  • rights
    Information on the document's copyright.
  • version
    The document version.
  • created-on
    The date and time when the document was created. By default, this is the date and time at instance creation.
Represents a section in the document. Unlike HTML, where a section is just another element, sections in CommonDoc contain their contents.
  • title
    The section title.
The base class of all document classes.
  • metadata
    Node metadata.
  • reference
    A unique string identifying the node.
A node with children. This is the base class of all nodes that have a children slot (Except document, since this class inherits from document-node) and can also be used as a way to represent a generic grouping of elements. This is useful when building a CommonDoc document by parsing some input language.
  • children
    The node's children.
A node representing a bare string of text.
  • text
    The node's text.
A paragraph.

    Inline Nodes

    The superclass of all inline markup elements.
      Text in this element is bold.
        Text in this element is italicized.
          Text in this element is underlined.
            Text in this element is striked out.
              Text in this element is monospaced or otherwise marked as code or computer output.
                Text in this element is superscripted relative to containing elements.
                  Text in this element is subscripted relative to containing elements.


                    A block of code.
                    • language
                      The language of the code block's contents.


                    The base class of all quotes.
                      A quote that occurs inside a paragraph in the document.
                        A block quote.


                          The base class for all links, internal and external.
                            A link to a section of this document, to another document and optionally a section within that document. See also the reference slot in the document class.
                            • document-reference
                              A reference ID for the linked document. If NIL, the link is only to a section within the document.
                            • node-reference
                              A reference ID for the linked node.
                            An external link.
                            • uri
                              The URI of the external resource.


                            The base class of all lists.
                              A list where the elements are unordered.
                              • children
                                The list of list-item instances.
                              A list where the elements are ordered.
                              • children
                                The list of list-item instances.
                              A list of definitions.
                              • children
                                The list of definition instances.
                              The item in a non-definition list.
                                An item in a definition list.
                                • term
                                  The definition term.
                                • definition
                                  Defines the term.

                                Images & Figures

                                An image.
                                • source
                                  The source where the image is stored.
                                • description
                                  A plain text description of the image.
                                A figure, an image plus an annotation.
                                • image
                                  The figure's image.
                                • description
                                  A description of the image.


                                A table.
                                • rows
                                  The list of rows in a table.
                                A row in a table.
                                • header
                                  The row header.
                                • footer
                                  The row footer.
                                • cells
                                  The cells in the row.
                                A cell in a table.


                                  make-content(children &key metadata reference)
                                  Create a content node from its children.
                                  make-text(string &key metadata reference)
                                  Create a text node from the contents of a string.
                                  make-paragraph(children &key metadata reference)
                                  Create a paragraph node from its children.
                                  make-bold(children &key metadata reference)
                                  Create a bold node from its children.
                                  make-italic(children &key metadata reference)
                                  Create an italicized node from its children.
                                  make-underline(children &key metadata reference)
                                  Create an underlined node from its children.
                                  make-strikethrough(children &key metadata reference)
                                  Create an striked out node from its children.
                                  make-code(children &key metadata reference)
                                  Create an inline code node from its children.
                                  make-superscript(children &key metadata reference)
                                  Create a superscripted node from its children.
                                  make-subscript(children &key metadata reference)
                                  Create a subscripted node from its children.
                                  make-code-block(language children &key metadata reference)
                                  Create a code block node from its children and language.
                                  make-inline-quote(children &key metadata reference)
                                  Create an inline quote node from its children.
                                  make-block-quote(children &key metadata reference)
                                  Create a block quote node from its children.
                                  make-document-link(document reference children &key metadata)
                                  Create a document link from document and node references and its children.
                                  make-web-link(uri children &key metadata reference)
                                  Create a web link.
                                  make-list-item(children &key metadata reference)
                                  Create a list item.
                                  make-definition(term definition &key metadata reference)
                                  Create a definition list item.
                                  make-unordered-list(children &key metadata reference)
                                  Create an unordered list.
                                  make-ordered-list(children &key metadata reference)
                                  Create an ordered list.
                                  make-definition-list(children &key metadata reference)
                                  Create a definition list.
                                  make-image(source &key description metadata reference)
                                  Create an image.
                                  make-figure(image description &key metadata reference)
                                  Create a figure.
                                  make-table(rows &key metadata reference)
                                  Create a table from a list of rows.
                                  make-row(cells &key metadata reference)
                                  Create a row from a list of cells.
                                  make-cell(children &key metadata reference)
                                  Create a cell from its children.
                                  make-section(title &key children reference metadata)
                                  Create a section from its title and children.
                                  make-document(title &key children keywords &allow-other-keys)
                                  Create a document.


                                  We'll create an example document using the constructor functions:

                                  (in-package :common-doc)
                                  (make-document "My Document"
                                      (make-section (list (make-text "Introduction"))
                                            (list (make-text "...")))))))

                                  We can use the dump function to inspect the structure of this document:

                                  COMMON-DOC> (dump my-doc)

                                  Some examples of accessors:

                                  CL-USER> (in-package :common-doc)
                                  #<PACKAGE "COMMON-DOC">
                                  COMMON-DOC> (text (make-text "Hello, world!"))
                                  "Hello, world!"
                                  COMMON-DOC> (children (make-paragraph
                                                          (list (make-text "This is ")
                                                                (make-text "a test"))))
                                  (#<TEXT-NODE text: This is > #<TEXT-NODE text: a test>)
                                  COMMON-DOC> (children (make-paragraph (list (make-text "This is ") (make-text "a test"))))
                                  (#<TEXT-NODE text: This is > #<TEXT-NODE text: a test>)
                                  COMMON-DOC> (make-code-block "lisp" (list (make-text "(progn ...)")))
                                  #<CODE-BLOCK children: TEXT-NODE>
                                  COMMON-DOC> (language *)
                                  COMMON-DOC> (children **)
                                  (#<TEXT-NODE text: (progn ...)>)