Triv Specification

API version: 0.50.0

Specification document version: 0.50.0.2

A Triv document may include:

Element statements

An element statement is comprised of an element expression and optional content.

expression: content
Note: Extra space and tab characters before content on the same line as an element expression are ignored according to the default profile.

An element statement within another element statement is specified by indentation with a minimum of two space characters.

a:
  b:
    c:
Note 1: If the number of indentation spaces is odd, one space character is ignored. Note 2: Extra indentation spaces are output as extra spacing.

Element expressions

An element expression is comprised of one or multiple elements.

There is no tab or space between multiple elements condensed into a single element expression.

a:b:c:

Elements

An element is the basic unit of a Triv document.

A name and placement mark are normally necessary for the definition of an element.

Note: A name may be optional according to the default profile for Triv, as described in Default element.

Optional features may include:

Element name

An element is specified by an element name.

Recommended: Special characters (<, >, &) are recommended not to be included. Note 1: The irregular character (/) is not permitted as the initial or final character. Note 2: Reserved characters ([, ], ", ') are not permitted.

Default element

If an element name is not specified, the default name according to the default profile is assumed to be: div.

If a model element is specified, the name of the default element is that of the model element.

Note: Only a default element with an AWM is considered valid according to the default profile.
:
<div></div>
Model element

A model element is specified by the first element with a present but empty attribute string.

Note: Only a model element with an AWM is considered valid according to the default profile.
a[]:
:
<a></a>
<a></a>

Optional features

Optional features for an element are of the form:

name#id.class1.class2.class3[attributes]?:
ID

An id attribute may be specified by a leading hash mark (#) before an attribute string, if any.

a#id:
<a id="id"></a>
Class list

A class list attribute may be specified by a leading period (.) before an attribute string, if any.

Multiple classes may be specified.

a.class:
<a class="class"></a>
Attribute string

An attribute string may be specified before the placement mark.

Matching square brackets ([ and ]) denote an attribute string.

Recommended: Special characters ([, ], <, >) are recommended to be quoted with a quotation mark (" or ').
a[a="a"]:
<a a="a"></a>
Postfix

A postfix may be specified by a special character as the final part of an element, before the placement mark.

The only value of a postfix is cleaner syntax. The same effect may be achieved by the character in the attribute string.

Note: A postfix is output with one initial space character, unless the final part of the attribute string is a quotation mark (" or ') or a space or tab character.

Characters: ~!@#$%^&*-_+;,?

a?:
<a ?></a>

Placement mark

A placement mark is necessary for further contents to be placed within an element statement.

The placement mark of the last element in an element expression determines the placement mark of every element in the expression.

AWM

A colon character (:) as the final part of an element is an AWM (array-wise mark).

a:
<a></a>
BWM

A pipe character (|) as the final part of an element is a BWM (block-wise mark).

a|
<a></a>
Self-closing mark

One or two forward slash characters (/ or //) as the final part of an element is a self-closing mark.

Note: An element with a self-closing mark must specify an attribute string. The attribute string may be empty.

Further contents are not placed within an element statement with a self-closing mark.

A fully self-closing element, with two forward slash characters, outputs an element with a single forward slash.

a[]//
<a/>

A void self-closing element, with one forward slash character, outputs an element with no forward slash.

a[]/
<a>

Native elements

Any content text that is expected to be recognized by a downstream application as an element is referred to as a native element.

Other than in a convenience literal, native elements are not modified.

a: <b>n</b>
<a><b>n</b></a>

Sections

A section is specified by a title.

Matching square brackets ([ and ]) around valid text denote a section title.

Note 1: A title consisting only of space and/or tab characters is not permitted. Note 2: A title consisting only of multiple dot characters (.) is not permitted. Note 3: Reserved characters ([ and ]) are not permitted.
[A]
n
<div><h1>A</h1>
  n
</div>

Optional features are specified with decorators.

Note 1: Special characters (<, >, &) are output as the corresponding XML character reference in a section header according to the default profile. Note 2: An ampersand (&) as part of an XML character reference (i.e. &#0000;) is output without modification.

Section indentation

Sections are output indented by one indent for each previously open section.

The contents of a section are output indented further by one indent.

[A]
[.B.]
[..C..]
n
<div><h1>A</h1>
  <div><h1>B</h1>
    <div><h1>C</h1>
      n
    </div>
  </div>
</div>

Generated output indentation for content may be avoided with a justified literal.

Section level

If no other section is open, a section is output within the most recently open element that has no content.

Note: Content always refers to condensed content, default content, or a content literal.

If another section is open, a section is output directly within the section of just greater level, according to section level indicator.

A greater number of matching outer square brackets ([ and ]) around a section title correspond to a larger section level.

A greater number of matching dot characters (.) around a section title correspond to a smaller section level.

[[A]]
[B]
[.C.]
<div><h1>A</h1>
  <div><h1>B</h1>
    <div><h1>C</h1>
    </div>
  </div>
</div>

Decorators

A section decorator string may be specified after a section title.

A decorator string may include:

A section with a decorator string is of the form:

[Title]# heading/section property & attributes

A decorator string may be distanced from the title by at most three characters.

Note: Two of the distancing characters may be spaces. One character may be an ID mark.

ID mark

An ID mark section decorator is specified with a hash mark (#).

A section with an ID mark outputs an element with the ID property value set to the section title.

Space characters in the title are output as underscores in the ID property value.

A title with a quotation mark (" or ') when output to an ID property value is quoted with the other corresponding XML quotation mark.

If both quotation mark character types are present, the double-quotation mark character (") is output as a backquote character (`) in the ID property value.

The heading element is not output if an ID mark is present, unless a heading element name is also present as a decorator according to the default profile.

[The Title]#
<div id="The_Title">
</div>

Heading element name

A heading element name section decorator is specified as the initial decorator.

If a heading element name is not specified, the default name is assumed to be h1 according to the default profile.

If a heading element name is omitted with a forward slash character (/) as part of the section element name decorator, a heading element is not output.

Note: A space or tab character is not permitted trailing a heading element name if a section element name is specified.
[A] b
<div><b>A</b>
</div>

Section element name

A section element name section decorator is specified by a leading forward slash character (/).

If a section element name is not specified, the default name is assumed to be div according to the default profile.

Note: The reserved character (/) is not permitted.
[A]# /a
<a id="A">
</a>

Title property name

A title property name section decorator is specified as the decorator after the section element name.

[The Title] / title
<div title="The Title">
</div>

If an ID mark is present, the title property name functions as the name of the ID property.

[The Title]# / name
<div name="The_Title">
</div>

Attribute

An attribute section decorator may be specified with an optional leading ampersand character (&).

Alternatively, an attribute decorator may be specified as the decorator after the title property name.

Note: A single space character around the location of the leading ampersand is ignored. Any additional spacing is output before the attributes. Recommended: Special characters (<, >, &) are recommended to be quoted with a quotation mark (" or ').
[A] & a="a"
<div a="a"><h1>A</h1>
</div>

Section closers

A section closer is specified by matching square brackets ([ and ]).

The most recently opened section is closed by a single recent section closer.

[A]
a
[]
nnn
<div><h1>A</h1>
  a
</div>
nnn

A section is output within the same element as the immediately preceding section even if the preceding section was closed.

a:
[B1]
[]
[B2]
[]
<a>
<div><h1>B1</h1>
</div>
<div><h1>B2</h1>
</div>
</a>

Multiple recent section closer

Multiple sections may be closed by a multiple recent section closer with matching square brackets grouped within one another.

[A]
[.B.]
[..C..]
[[]]
aaa
<div><h1>A</h1>
  <div><h1>B</h1>
    <div><h1>C</h1>
    </div>
  </div>
  aaa
</div>

Section reset

A section reset is specified by a single set of matching square brackets with a final asterisk character (*).

All previously opened sections are closed by a section reset.

[A]
[.B.]
[..C..]
[]*
nnn
<div><h1>A</h1>
  <div><h1>B</h1>
    <div><h1>C</h1>
    </div>
  </div>
</div>
nnn

Literals

A literal is specified by a leading and trailing toggle.

Note: The toggle and text of the literal must not be on the same line according to the default profile.

Padding and indentation

Condensed literals

A literal with a leading toggle on the same line as an element statement is referred to as condensed.

A condensed literal is output with no spaces, tabs, or newlines as padding.

a: """
nnn
"""
<a>nnn</a>

Justified literals

A literal with a trailing toggle with no initial spacing or indentation is referred to as justified.

A justified literal is output with no generated section indentation.

[A]
'''
not justified
  '''
"""
justified
"""
<div><h1>A</h1>
  not justified
justified
</div>

Content literals

A content literal is toggled by tripled quote characters (""" or ''' or ```).

Common literals

A common content literal, a.k.a. common literal is toggled by tripled double-quote characters (""").

[A] #/a
b:

  """
  not:elements:
  """
<a id="A">
  <b>

    not:elements:

  </b>
</a>

The special case of a condensed and justified common literal is referred to as a verbatim literal or true literal.

a: """
not padded
"""

a: """
<not-shortened></>
"""
<a>not padded</a>

<a><not-shortened></></a>

Convenience literals

A convenience content literal, a.k.a. convenience literal is toggled by tripled single-quote characters (''').

A native element in a convenience literal may optionally omit the element name in the closing tag.

Note: A native element that wraps another native element may not omit the element name in the closing tag according to the default profile.
'''
<a></>
'''
<a></a>

Publication literals

A publication content literal, a.k.a. publication literal is toggled by tripled backquote characters (```).

Special characters (<, >, &) are output as the corresponding XML character reference in a publication literal.

```
<a>&</a>
```
&lt;a&gt;&amp;&lt;/a&gt;

Comment literals

A comment literal is toggled by a tripled exclamation character (!!!).

Note: Any dash character (-) immediately after another dash character in a comment literal is output with a space between.
!!!
comment
--
comment
!!!
<!--
comment
- -
comment
-->

Comments

A single-line comment is specified by a line with a leading left angle bracket (<).

Spacing between the comment character and comment text is repeated on the other side of the comment text in the output.

Note: Any dash character (-) immediately after another dash character in a comment literal is output with a space between.
< single -- comment
<!-- single - - comment -->

A comment spanning multiple lines may be specified as a comment literal.

Note: An internal comment producing no output is not defined according to the default profile.

Native comment

Any text that is expected to be recognized by a downstream application as a comment is referred to as a native comment.

Note: A native comment is not validated.
a: n <!-- native comment -->
<a>n <!-- native comment --></a>

Content

Text not specified as a content literal may be condensed content or default content.

Condensed content

Condensed content is text that is on the same line as an element expression.

After the necessary placement mark, condensed content is specified by a single leading space or tab character.

Note Additional leading spacing is ignored in the default profile.
a: condensed content
<a>condensed content</a>

Default content

Default content is text that does not fit into any other category.

element:
  default content

default content
<element>
  default content
</element>

default content

Padding

Padding is specified by matching newlines around an indented node placed within an element.

Note: ‘Node’ refers to an element statement, section, literal, or default content.

Padding outputs newlines around the node.

Blank lines are specified by non-matching newlines around any node.

Blank lines output newlines before or after the node.

a1:

  b1:



a2:
<a1>

  <b1></b1>

</a1>


<a2></a2>