I am very pleased to announce the second release of the Glyph Document Authoring Framework. For those who don’t know, Glyph is a pure-Ruby, extensible solution to author documents like books or articles using a simple, fully-customizable markup language.

Since the first release, came out, last month, a lot happened. Plenty of bugs were fixed and new features implemented, as shown by the changelog. Here’s a brief rundown of the most notable changes.

What Glyph code looks like Earlier this week I blogged about my new Glyph vim syntax file. I’ve been using it for a while, and all I can say is that it really helps! Here’s what it looks like: I’m sorry for the Emacs and TextMate folks, but I only use Vim, so I only made a Vim syntax file. Anyhow, Glyph grammar is very simple, so rolling out your own syntax file for your favorite editor shouldn’t be too hard.

Notable features Single-file compilation Perhaps the most life-changing feature in this release is the possibility of compiling a single Glyph source file into an HTML or PDF file. This means you no longer need to create a full-blown project for writing a short article: just create a file anywhere and run glyph compile filename.glyph on it! The good thing is that with this new release you can also define snippets, configuration settings, and even macros right into your Glyph files, so you can do almost anything without having to create a project or fiddle with YAML files. Programmatic usage The second most notable feature is the possibility to use Glyph as a Ruby library, i.e. as you’d use a filter like RedCloth or MarkDown. Additionally, it is also possible to compile single files programmatically, so you can, for example, create PDF files for your articles from the same source file. Don’t believe me? Feel free to click the Download PDF and View Source links on this very page to see for yourself… For those of you using the awesome nanoc static site generator, here’s a few source files you may want to take a look at: lib/glyph-data.rb — How to update configuration settings.

lib/glyph-data.rb — a simple Glyph filter.

Rules — a rule using the Glyph#compile method to generate PDF files. Auto-regeneration Another very interesting feature is the possibility to auto-regenerate your output files automatically whenever a source file is changed. Just run glyph compile --auto and you’re away. I’d like to thank Sebastian Staudt for proposing, implementing, and testing this feature. Conditional macros Finally, although it may worry some, I added the possibility to evaluate conditional expressions directly in Glyph. The syntax is a bit verbose due to the extreme simplicity of Glyph parser, but it does the job: ?[and[ eq[$[document.output]|pdf]| eq[$[tools.pdf_generator]|prince] ]| style[pagination.css]] The snippet above can be used to include the pagination.css stylesheet only when generating a PDF file with Prince XML.