Glyph - XML Fallback

← Textile or Markdown | Contents | Adding Stylesheets →

Sure Textile and Markdown are great, but sometimes you may want to just use HTML, without the extra verbosity, of course. Take tables for example: Textile offers an easy way to create them, but things may get dirty when you need to have multiple paragraphs or lists within cells.

Very early versions of Glyph used to offered some simple table, tr, tr, td macros just for that. Of course the problem was that thy didn't offer any way to customize the markup by adding, for example, CSS classes.

Instead, by default, Glyph can convert any unrecognized macro to the corresponding XML element and macro attributes to XML attributes.

Example

The following Glyph code:

 1table[@class[features]
 2  tr[
 3    th[ID]
 4    th[Priority]
 5    th[Description]
 6  ]
 7  tr[
 8    td[27]
 9    td[span[@style[color:red;font-weight:bold;] HIGH]]
10    td[HTML output]
11  ]
12  tr[
13    td[42]
14    td[span[@style[color:green;font-weight:bols;] LOW]]
15    td[
16      p[Support for less-used tags:]
17      ul[
18        li[cite]
19        li[sup]
20        li[...]
21      ]
22    ]
23  ]
24]

Is translated into the following HTML code:

 1<table class="features">
 2  <tr>
 3    <th>ID</th>
 4    <th>Priority</th>
 5    <th>Description</th>
 6  </tr>
 7  <tr>
 8    <td>27</td>
 9    <td><span style="color:red;font-weight:bold;">HIGH</span></td>
10    <td>HTML output</td>
11  </tr>
12  <tr>
13    <td>42</td>
14    <td><span style="color:green;font-weight:bold;">LOW</span></td>
15    <td>
16      <p>Support for less-used tags:</p>
17      <ul>
18        <li>cite</li>
19        <li>sup</li>
20        <li>...</li>
21      </ul>
22    </td>
23  </tr>
24</table>

Basically, if the options.xml_fallback setting is set to true, any macro unknown to Glyph with at most one parameter will be converted to an XML tag with the same name and any attribute will be converted to the corresponding XML attribute.

ImportantWhile macro names and attributes are validated so that an error is returned if they contain illegal character, no check is performed against any particular XML schema.

Additionally, it is possible to force macro-to-XML conversion by composing the name of a tag with the xml macro, so for example xml/snippet[test] will be converted into <snippet>test</snippet>.

Blacklisted XML tags

By default, the following tags are blacklisted and will be ignored:

  • applet
  • base
  • basefont
  • embed
  • frame
  • frameset
  • iframe
  • isindex
  • meta
  • noframes
  • noscript
  • object
  • param
  • title

TipYou can change this list by modifying the options.xml_blacklist setting.

← Textile or Markdown | Contents | Adding Stylesheets →