Glyph - Links and Bookmarks

← Topics | Contents | Images and Figures →

Lightweight markups let you create internal and external links in a very easy way, and you can still do so in Glyph. However, if you do so:

  • you can’t check if they are valid
  • you can’t infer the link title automatically

If you care about link validation and you want to save some keystrokes, then you should use:

  • the link macro (aliased to =>) — to create internal and external links.
  • the anchor macro (aliased to #) — to create named anchors (bookmarks) within your document.
Example

The following Glyph code:

1This is a link to link[#test].
2...
3This is link[#wrong].
4This is a #[test|test anchor].

Is translated into the following HTML code:

1<p>This is a link to <a href="#test">test anchor</a>.</p>
2<p>...</p>
3<p>This is <a href="#wrong">#wrong</a>.</p>
4<p>This is a <a id="test">test anchor</a>.</p>

Additionally, the following warning message is displayed when compiling:

1warning: Bookmark 'wrong' does not exist
2 -> source: @: authoring.textile
3 -> path: document/body/bodymatter/chapter/@/textile/section/section/box/link

Basically, if you use the link macro and the anchor macro, Glyph makes sure that:

  • all links point to valid anchors within the document (regardless if the anchors are before or after the link, in snippets or included files).
  • there are no duplicate anchors within the documents.
  • if no title is specified as second parameter for the link macro, the anchor’s name is used as such.

Besides using the anchor macro, you can also create an anchor for a header by passing an @id attribute the the section macro, like this:

1section[
2  @title[My Section]
3  @id[my_section]
4...
5]

By default, validation is only enabled for internal links (i.e. the check occurs if the first parameter of the link macro starts with a #). You can enable it for external links as well by setting the options.url_validation setting to true. If URL validation is enabled, an error is returned if a link returns an HTTP status greater than 302.

ImportantEnabling URL validation may significantly slow down compilation if a lot of external links are present.
← Topics | Contents | Images and Figures →