Skip to content

Instantly share code, notes, and snippets.

@Uradamus
Last active February 5, 2018 02:38
Show Gist options
  • Save Uradamus/81fb0081fd9abfe352c9 to your computer and use it in GitHub Desktop.
Save Uradamus/81fb0081fd9abfe352c9 to your computer and use it in GitHub Desktop.
Terse Markup Language 0.1 Specification

TML

TML is an acronym for Terse Markup Language. It is intended as a light weight syntax alternative to XML and other similar markup languages. Development of TML was begun by Ian S on April 8, 2013. TML is an open specification that is free to use by all for any purpose.

Example TML document

[!TML, version="0.1", encoding="UTF-8"]

[example element hierarchy:
    [element1: "An element with a name attribute and a value."]
    [element2, attr2='An element with two attributes, but no value.']
    [element3, attr2 = An element with two attributes: "and a value."]
    [element4 : ```This is a raw string that won't be parsed for syntax,
		It can go on for as many lines as you like and include syntax
		symbols such as these [, ], ", ', : without worry about how
		they will be parsed.```]
    # This is a comment, it begins and ends with hashes/octothorpes.
      TML ignores white space and comments, but good use of them
      helps readability. #
]

Terminology

###Element An element is the base building block of a TML document. Elements always start and end with square braces ( [ ] ). One or more elements can be nested as the element value of another element to form a hierarchy. At the very minimum an element must have a name attribute that always comes first. They can optionally have additional attributes as needed separated by commas ( , ). Elements may also optionally contain a value as well, which is separated from the attribute list by a colon ( : ). The first element should be a header containing three attributes: the text "!TML" as the name attribute, the version of TML used and the encoding used by the document.

###Attribute Attributes define an element. The first attribute is always the element's name. Any additional attributes are defined as name/value pairs with the name and value separated by an equal sign ( = ). Each attribute is separated by a comma ( , ). Further rules concerning attribute values can be found in the following element value section. If an element does not have an element value, then the colon ( : ) is optional and should generally be left out.

###Element Value Element values are optional. When an element value is needed they must follow a colon ( : ) that separates them from the element's attribute(s).

The following concerns both element values and attribute values. Values can be either strings or one or more additional elements. Values should be surrounded by matching single quotes ( ' ) or double quotes ( " ). Though quotation marks are optional so long as the value does not contain a comma ( , ), colon ( : ), quotation marks ( ' " ) or brackets ( [ ] ). If raw string data that shouldn't be parsed is required for a value then you should surround the value with three consecutive grave accent marks ( ``` ). Raw string values will be fed as is with syntax symbols and newlines intact.

###Comment Comments always begin and end with a hash/octothorpe ( # ). They can span as many lines as needed. Everything between the hash symbols are ignored by the parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment