O Markup Language

This document specifies the O Markup Language (OML). N.B. This English translation is manually done by the author. It would be greatly appreciated if you improve fluency by sending patches!

ASCII symbol characters which form left/right pairs, namely, (<[{ (}]>)) are called as left/right beaks. Other 24 ASCII symbol characters, namely, !"#$%&'*+,-./:;=?@\^_`|~ are called as eyes. A null character is replaced with a substitution character if a character encoding supports, otherwise they are removed.

A represented document consists of a sequence of nodes. An element has a label as a string, and a sequence of zero or more child nodes. A node is either a text or an element. A nesting of an top level element is equal or greater than 32. A left head has a beak and an eye, and a right head has an eye and a beak, in these orders. Left and right heads match when the beak and the eye are identical. A vocaburary is a mapping from a head to a label. A special element which changes the vocabulary while parsing is called as vocaburary shift.

While parsing, a left head is prioritized over a right head. A left head is produced 1) always for the first time or within vocabulary shifts, or 2) otherwise when a vocabulary has the head.

A right head is produced when it matches with the closest left head which has not closed yet. The production makes nodes between heads as a sequence of child nodes, and forms an element. If there are left heads which have not closed yet in a child node sequence, it is assumed that there is a right head matching with this left head right before the right head, and so on.

In a child node sequence of a vocabulary shift, if there comes an element which has a text first, it adds a left head to a label mapping to the vocabulary. If an element comes first, it moves the label in the vocabulary from the internal left head to the external one.

The language is now fully specified. The remainder of this document is non-normative.

Examples

This section presents examples, which are accompanied by their JSON outputs, enabling conformance testing against this document. The JSON output follows the JSON schema below, which represents the abstract syntax tree.


{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:local:oml-ast.schema.json",
  "title": "Sample AST",
  "type": "array",
  "items": { "$ref": "#/$defs/node" },
  "$defs": {
    "node": {
      "anyOf": [
        { "type": "string" },
        { "$ref": "#/$defs/element" }
      ]
    },
    "element": {
      "type": "object",
      "properties": {
        "label": { "type": "string" },
        "children": {
          "type": "array",
          "items": { "$ref": "#/$defs/node" }
        }
      },
      "required": ["label", "children"],
      "additionalProperties": false
    }
  }
}

If a label is not in the vocabulary, no element is created.

<! !>(+a+)
["(+a+)"]

The minimal vocabulary change:

<!(*a*)!>(*b*)
[{"label":"a","children":["b"]}]

After the element head move, the past mapping in the vocabulary has gone.

<! (+a+) (*(+ *) !>(+b+)(*c*)
["(+b+)",{"label":"a","children":["c"]}]

The vocabulary shift can also be swapped to an another head.

<! <?<! ?> !><?(+a+)?><!b!>(+c+)
["<!b!>",{"label":"a","children":["c"]}]

Left heads which have not closed yet will close at the end of the document. Here, it is a vocabulary shift, so it becomes empty.

<!
[]

Changelog

The 9th edition, 2026-08-19. Omitted a second eye. Stripped spaces within the elements. Altered conditions to form elements. Appended about null characters handling. Updated the default left head for the default vocabulary shift from the fixed one. In May 21, we released this language and the reference implementation. In 2025-04-27, we make the acronym of this languege to OML. In 2023-05-21, the first edition. This language is inspired by TeX, XML, and Djot.

License

Copyright (C) 2023-2026 gemmaro.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.