Previous: , Up: API  


1.3 (orgwebalchemy peg)

1.3.1 Parameters

Parameter: element-names

Default value:

()

1.3.2 Procedures

Procedure: document-names nodes

Return the names the elements of the parsed document nodes carry.

Procedure: figure-parts node

Return (name caption target description) for the figure node. Every part the figure does not have comes back as #f.

Procedure: group-list-items items

Group consecutive items of the same kind into (kind . items) runs, preserving their original order. One Org list may mix unordered, ordered and description items, so each run becomes a list element of its own.

Procedure: heading-parts children

Return (todo priority tags text) for the children of a heading. A heading is split into these by process-ast; anything it does not have comes back as #f, except the tags, which are the empty list.

Procedure: inline-nodes ast

Return ast as a list of nodes, whatever shape it came in. A parser hands back one node, a list of nodes or nothing at all, depending on what it matched; this is the one place that shape is flattened.

Procedure: inline-org->ast text

Parse inline Org-mode markup from text. Applies the inline-content PEG pattern to process bold, italic, raw URLs, inline code, and links, returning the resulting AST. A link whose bare target names an element of the document being rendered resolves to that element; see element-names.

Procedure: list-item-kind item

Return the kind of a list item: unordered, ordered, description or other.

Procedure: named-parts node

Return (name element) for the named element node.

Procedure: org->ast str

Parse an entire Org-mode document string str into an Abstract Syntax Tree. This is the main entry point for the parser. It matches the org-doc PEG pattern and then applies process-ast to resolve hierarchical constructs like nested lists, folds ‘#+NAME:’ and ‘#+CAPTION:’ keywords into the elements they describe, and resolves a link whose bare target names an element of the document. A single top-level element comes back as that element’s node; several come back as a list of nodes.

Procedure: org-anchor text

Return a URL-fragment-safe anchor for text. Lower-case letters and digits survive, every run of anything else becomes a single dash, and leading or trailing dashes are dropped: ‘My First Section’ becomes my-first-section. Headings carry this as their id and ‘*Heading’ links point at it, so the two agree by construction.

Return #t when the Org link target should render as an image. A ‘file:’ link (or a bare path) whose extension is one of org-image-extensions counts, as does a data:image/... URI.

Return the text Org shows for a link target that has no description. An internal or heading link shows its id or title, a file link its path, and a link with a scheme of its own the full URL.

Return the href an Org link target should point at. File links give their path, ‘#custom-id’ and ‘*Heading’ links give a local fragment, and a link with a scheme of its own keeps it.

Split the Org link target into (protocol . path). protocol is a symbol:

  • http, https, mailto, data and friends, for a link that carries a URL scheme of its own;
  • file for a file: link and for a bare path such as notes.org;
  • internal for a #custom-id link;
  • heading for a *Heading link.

path is target with its prefix removed and with any ‘::search’ suffix dropped, so it is ready to be used as an href or a file name. org-link-search returns that suffix separately.

Return the path of the Org link target, without protocol or search part.

Return the protocol symbol of the Org link target. See org-link-parts for the possible values.

Return the ‘::search’ part of the Org link target, or #f. This is the *Heading' or #anchor that a file link points inside the linked document; it is not something the renderers act on yet.

Procedure: split-checkbox text

Return (state . rest) when text starts with an Org checkbox. state is #t for ‘[X] ’/‘[x] ’ and #f for ‘[ ] ’; rest is the item text with the checkbox removed. Returns #f when text is not a checkbox item.

Procedure: trim-whitespace str

Return str without leading or trailing spaces and tabs.


Previous: (orgwebalchemy markdown), Up: API