Glyph - Sections and Headers

Glyph documents are normally organized as a hierarchical tree of nested chapters, appendixes, sections, etc. To define a section, use the section macro (aliased by §), like so:

2  @title[Section #1]
3Write the section contents here...
4  section[
5    @title[Section #2]
6This section is nested into the previous one.
7  ] --[End of Section #2]
8] --[End of Section #1]

This example defines two nested sections. If the @title attribute is specified like in this case, it will be converted to a proper HTML header and it will appear in the Table of Contents (see the toc macro).

Note an important difference from HTML: there is no need for an explicit level for the headers, as it will be determined at runtime when the document is compiled, based on how sections are nested. The previous code snippet (taken as it is), for example, will be transformed into the following HTML code:

1<div class="section">
2  <h2>Section #1</h2>
3  <p>Write the section contents here...</p>
4  <div class="section">
5    <h3>Section #2</h3>
6    <p>This section is nested in the previous one</p>
7  </div>

By default, in Glyph the first header level is 2, so the two headers are rendered as h2 and h3, respectively (--[...] macros are comments, therefore they are not included in the final output).

Markup-aware sections

Although Glyph can be used on its own to produce valid HTML or XML code, you may often want to use Textile or Markdown to save some typing. Typically, you’ll end up writing a lot of code like this:

2  @title[My Textile section]
3  textile[
4Textile markup can be used _here_.
5  ]

To save you even more typing, you can use the textile_section macro (aliased by txt_section and §txt) and the markdown_section macro (aliased by md_section and §md). By doing so, the previous code snippet can be written like this:

2  @title[My Textile section]
3Textile markup can be used _here_.