Glyph was created wih extensibility in mind. You can freely extend Glyph Language by creating or overriding macros, to do whatever you like. Macro definitions are written in pure Ruby code and placed in .rb files within the lib/macros/ folder of your project.
This is the source code of a fairly simple macro used to format a note:
The macro method takes a single Symbol or String parameter, corresponding to the name of the macro. In this case, the entire block (or body of the macro) is a String corresponding to what we want the macro to evaluate to: a <div> tag containing a note.
The body of the macro is evaluated in the context of the Glyph::Macro class, therefore its instance variables (like @name or @value) can be used directly.
The following table lists all the instance variables that can be used inside macros:
A Glyph::MacroNode containing information about the macro. Useful for accessing parent and child macros, and the current Glyph::Document. Normally, instances of the MacroNode class contain the following keys:
:name, the name of the macro.
:source, a String identifying the source of the macro (a file, a snippet, etc.)
:value, the value of the macro (populated after the document has been parsed and analyzed).