2.3 - A Brief Introduction to Styles and Built-Ins

See also:  [ghost] ,  [glos] ,  [gstyle] ,  [listg] ,  [locs] ,  [spage]  and  [style] 

Styles are the heart of what class   macro()   is about. The built-ins you'll be reading about throughout this manual are the low-level bricks and mortar that get things done, but styles are how you get things done cleanly and easily and sanely using the built-ins. They also let you go beyond the built-ins into wholly custom text generation.

2.3.1 - Built-ins

You specify a built-in using square brackets. Here's how to do HTML italics. What happens is that the built-in named "i" receives "my text" as content. It then wraps HTML italics tags around that content, and returns it that way:

[i my text]

<i>my italic text</i>

2.3.2 - Styles

Here are the components of a style:

You can easily create a style to do the exactly same thing as the built-in:

[style i <i>[b]</i>]
{i my italic text}

<i>my italic text</i>

aa_macro's built-ins are designed with an eye towards HTML rendering. But perhaps you have a need to generate text to be processed by something other than a web browser (such as markdown, which has to be processed further) where italics are indicated by underscore. In that case, you'd do this:

[style i _[b]_]
{i my italic text}

_my italic text_

Advanced use: You can invoke multiple styles on single or multiple contents in one operation. See  [s]  for examples of this.

You can write sets of styles and place them in files to be included in your projects. So you can write styles that generate, for instance, HTML and markdown from the same source documents. In fact, I do that very thing using the aagen command in the aa_macro repo to generate the quick reference documentation:

aagen -i qr_html.txt -f quickref.html quickref.txt -r aagen -i qr_markdown.txt -f quickref.md quickref.txt -r

On the first line, the  -i qr_html.txt  includes styles that generate to HTML.

On the second line, the  -i qr_markdown.txt  includes styles that generate to markdown.

Both command invocations take  quickref.txt  as the primary source input, and each generates to a different file,  quickref.html  and  quickref.md  respectively.

See also:  [ghost] ,  [glos] ,  [gstyle] ,  [listg] ,  [locs] ,  [spage]  and  [style] 

Keyboard Navigation
, Previous Page . Next Page t TOC i Index

Valid HTML 4.01 Loose

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses python 2.7