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.
Metadata
make-meta(pairs)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
documentA document.
Metadata is mostly based on Dublin Core and the OpenDocument format.
childrenThe document's children nodes.titleThe document's title.creatorThe creator of the document.publisherThe document's publisher.subjectThe subject the document deals with.descriptionA description of the document.keywordsA list of strings, each being a keyword for the document.referenceA reference string to uniquely identify the document within a certain context.languageAn RFC4646 string denoting the language the document is written in.rightsInformation on the document's copyright.versionThe document version.created-onThe date and time when the document was created. By default, this is the date and time at instance creation.
sectionRepresents a section in the document. Unlike HTML, where a
section is just another element, sections in CommonDoc contain their contents.
titleThe section title.
document-nodeThe base class of all document classes.
metadataNode metadata.referenceA unique string identifying the node.
content-nodeA 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.childrenThe node's children.
text-nodeA node representing a bare string of text.
textThe node's text.
paragraphA paragraph.
Inline Nodes
markupThe superclass of all inline markup elements.
boldText in this element is bold.
italicText in this element is italicized.
underlineText in this element is underlined.
strikethroughText in this element is striked out.
codeText in this element is monospaced or otherwise marked as
code or computer output.
superscriptText in this element is superscripted relative to containing
elements.
subscriptText in this element is subscripted relative to containing
elements.
Code
code-blockA block of code.
languageThe language of the code block's contents.
Quotes
base-quoteThe base class of all quotes.
inline-quoteA quote that occurs inside a paragraph in the document.
block-quoteA block quote.
Links
linkThe base class for all links, internal and external.
document-linkA 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-referenceA reference ID for the linked document. IfNIL, the link is only to a section within the document.node-referenceA reference ID for the linked node.
web-linkAn external link.
uriThe URI of the external resource.
Lists
base-listThe base class of all lists.
unordered-listA list where the elements are unordered.
childrenThe list oflist-iteminstances.
ordered-listA list where the elements are ordered.
childrenThe list oflist-iteminstances.
definition-listA list of definitions.
childrenThe list ofdefinitioninstances.
list-itemThe item in a non-definition list.
definitionAn item in a definition list.
termThe definition term.definitionDefines the term.
Images & Figures
imageAn image.
sourceThe source where the image is stored.descriptionA plain text description of the image.
figureA figure, an image plus an annotation.
imageThe figure's image.descriptionA description of the image.
Tables
tableA table.
rowsThe list of rows in a table.
rowA row in a table.
headerThe row header.footerThe row footer.cellsThe cells in the row.
cellA cell in a table.
Constructors
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.
Examples
We'll create an example document using the constructor functions:
(in-package :common-doc)
(make-document "My Document"
:children
(list
(make-section (list (make-text "Introduction"))
:children
(list
(make-paragraph
(list (make-text "...")))))))We can use the dump function to inspect the structure of this document:
COMMON-DOC> (dump my-doc)
document
section
paragraph
text-node
"..."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 *)
"lisp"
COMMON-DOC> (children **)
(#<TEXT-NODE text: (progn ...)>)