Too much time passed since the last Glyph release. Way too much. Finally I found the time and will to tidy up the last few remaining bugs, update the docs, and release it!
This new release was mainly focused on extending the features of Glyph as a language. Besides a few improvements that make writing Glyph code easier and more readable (e.g. macro composition), Glyph is now Turing-complete. It supports iterations, recursion, variable assignments, basic arithmetics… you can even write a program to compute the factorial of an integer, if you wanted to.
Additionally, it also features enhanced content reuse through fragments and output-independent macros, and a few bugfixes.
Although the support is still somewhat rough, you can, as a matter of fact, generate ebooks with Glyph, using Calibre.
This release features an update at syntax-level: the possibility of “composing” macros, thereby eliminating nesting provided that containers take only one parameter and no attributes. What? This:
Can be written like this:
In this case, the
not macro was composed with the
output? macro, thus removing one level of nesting.
Additionally, I used this features to create an
xml macro dispatcher that can be used to render raw XML tags, and an
s macro dispatcher that basically is able to call nearly all the instance methods of the Ruby String class. So you can write things like
s/sub[This feature makes my life easier|/my/|your] and similar.
As of this version, Glyph can be considered Turing-complete, as it satisfies the following requirements for Turing-completeness:
- A conditional construct, implemented via the
- Variable assignment, by setting the value of snippets using the
snippet:macro and of attributes using the
- (infinite) iteration implemented through the new
whilemacro or recursion, which is possible thanks to the new
- A memory model which emulates an infinite store: there are no enforced limits on attribute/snippets allocations and number of algorithms or parameters.
Plus, Glyph now understand basic integer arithmetic:
Not that you need to be able to calculate factorials in your documents, but know that now you can. An you can also define lexically scoped variables, err… attributes, like this:
Too lazy to create snippets? Feel the urge to re-use something you already wrote somewhere? Use a fragment and embed it, as follows:
…And you can also use a new
load macro, to embed entire files without performing any evaluation (like
To sum up:
snippets.ymlis no more, define all your snippets inside your document instead.
- New “invisible space separator”:
\.. Because it’s slightly prettier, nothing else.
rewrite:macro has been replaced by the
define:macro, which also allows recursion, so be careful!
- If you want to render raw XML tags, use
- No more
For the full list of the issues fixed in this release, see the Changelog.
Hope you’ll enjoy this new release of Glyph. If you want to contribute, go ahead and fork the repo!