.
If you want both an opening- and closing tag with no children, such as in
.Ql ,
then you can use an empty text-node as in
.Ql foo{-} .
.Ss Node names
Node names follow the exact same naming rules as names do in XML.
See the XML reference in
.Sx SEE ALSO
for more details.
.Ss Comments
Comments can be created by using the special
.Sq /
node name.
During transpilation any nodes named
.Sq /
and their children are commented out:
.Pp
.Bd -literal -offset indent
div {
/ p {-I am commented out}
p {-I am not commented out}
}
.Ed
.Ss Attributes
Attributes are optional components of a node.
They take the form of an attribute name and an optional attribute value.
To specify an attribute, simply write the attribute name:
.Pp
.Bd -literal -offset indent
name
.Ed
.Pp
If you want to provide a value, you must follow the name with an equals sign
.Pq Sq =
and then wrap the value in double quotes
.Pq Sq \(dq :
.Pp
.Bd -literal -offset indent
name="value"
.Ed
.Pp
You can optionally include whitespace for visual clarity, and double quotes and
backslashes
.Pq Sq \e
can be escaped using a backslash:
.Pp
.Bd -literal -offset indent
name = "he said \e"hello there\e""
.Ed
.Pp
Like with node names, the details about which characters are allowed within an
attribute name are detailed in the XML reference found in the
.Sx SEE ALSO
section of this manual.
.Ss IDs and classes
When transpiling, you will be wanting to use IDs and classes all of the time.
Due to the frequency of use of these parts of HTML,
.Nm
offers a shorthand syntax for specifying them.
The shorthand syntax looks like the equivalent CSS selectors for said IDs and
classes.
Valueless attributes prefixed with a period
.Pq Sq \&.
or hash
.Pq Sq #
are transpiled to classes and IDs respectively.
Therefore the following two examples are identical:
.Bd -literal -offset indent
div #foo .bar .baz {
div .bar {}
}
.Ed
.Bd -literal -offset indent
div id="foo" class="bar baz" {
div class="bar" {}
}
.Ed
.Pp
It is important to note that HTML5 allows for an ID- or class name to contain
just about anything, therefor
.Ql .→Ħ{}
is a valid class shorthand.
This is important because it means that the following doesn’t actually create a
node with no children:
.Bd -literal -offset indent
div .foo{}
.Ed
.Pp
You must instead include a space:
.Bd -literal -offset indent
div .foo {}
.Ed
.Ss Document types
.Nm
does not support document types.
The HTML5 document type is automatically generated when transpiling to HTML.
If you want to use a different document type, you’ll have to do that yourself.
There is an example of this in the
.Xr gsp 1
manual.
.Ss Literal text
If you want to include literal text within a node you can make use of the
special node name
.Sq - .
Unlike with the usual node name, you do not need to include whitespace between
the special node name and the attributes.
The following example shows how you can set a page title and paragraph text:
.Bd -literal -offset indent
html {
head {
title {-My Amazing Website}
}
body {
p {-
Welcome to my website! Here on my website you can find cute cat
pictures, amongst other things.
}
}
}
.Ed
.Pp
When writing literal text, all occurrences of
.Sq } ,
.Sq @ ,
and
.Sq \e
must be backslash escaped as they have special meaning.
.Ss Embedded nodes
If you want to embed a node within literal text, you can make use of an embedded
node.
Embedded nodes are exactly the same as regular nodes, but they are prefixed with
the at
.Pq Sq @
symbol.
For example if you want to emphasize some text in a paragraph, you could do the
following:
.Bd -literal -offset indent
p {-
This is some text, but @em .my-class {-some} of it is emphatic!
}
.Ed
.Ss Whitespace control
By default GSP transpiled to HTML will be automatically minified with the
exception of literal text whose whitespace is untouched.
Sometimes though, we want to have proper control over whitespace.
The first trick to manual whitespace control is to make use of the special node
name
.Sq = .
It acts identially to the special
.Sq -
node, except it removes all leading- and trailing whitespace:
.Bd -literal -offset indent
Before
p {= Hello World
}
After
Hello World
.Ed
.Pp
This can be useful for trimming whitespace, but sometimes we want to preserve
it.
This is especially crucial with HTML
.Ql
tags for which whitespace is not squashed.
We can get around this issue by making use of the fact that the special
.Sq -
node does not trim whitespace.
The following is an example of how not to display two seperate lines in a
.Ql
tag:
.Bd -literal -offset indent
Before
pre {
code{-Foo}
code{-Bar}
}
After
Foo
Bar
.Ed
.Pp
Instead, you can do the following:
.Bd -literal -offset indent
Before
pre {-
@code{-Foo}
@code{-Bar}
}
After
Foo
Bar
.Ed
.Pp
If you would like to have the whitespace between the opening- and closing
.Ql pre
tags and the inner
.Ql code
tags removed, you can use the
.Sq =
node instead of the
.Sq -
node.
.Sh SEE ALSO
.Xr gsp 1
.Pp
.Lk https://www.w3.org/TR/xml "Extensible Markup Language (XML) Reference"
.Sh AUTHORS
.An Thomas Voss Aq Mt mail@thomasvoss.com