all repos — h3rald @ 8354f51dd1763cbb13aaeb255cfc257e85f55e60

The sources of https://h3rald.com

Released Glyph 0.5.0.
h3rald h3rald@h3rald.com
Sun, 28 Aug 2011 21:17:55 +0200
commit

8354f51dd1763cbb13aaeb255cfc257e85f55e60

parent

3177bff01b4dbb18f7a6c2985e023542bc4a13df

A content/articles/glyph-050-released.glyph

@@ -0,0 +1,116 @@

+----- +:type: article +:tags: +- glyph +- ruby +- opensource +:permalink: glyph-050-released +:title: "Glyph 0.5.0 Released" +:subtitle: Featuring Calibre integration, macro composition, Turing-completeness, and more +:pdf: false +:date: 2011-08-28 21:18:00.000000 +02:00 +:intro: | + 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! +:extended_intro: | + 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. +----- +$[document.intro] + +§[ + @title[Calibre Integration] + txt[ +=>[https://github.com/tammycravit|Tammy Cravit] proposed (and more or less implemented) an interesting new feature: integrate =>[http://calibre-ebook.com/|Calibre] to generate ebooks in EPUB and MOBI format from Glyph's native standalone HTML output format. + +Although the support is still somewhat rough, you can, as a matter of fact, generate ebooks with Glyph, using Calibre. + ] +] +§[ + @title[Macro Composition] + txt[ +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: + ] + highlight[=html| +?[ + not[output?[pdf]]\| + ... +] + =] + +p[Can be written like this:] + + highlight[=html| +?[ + not/output?[pdf]\| + ... +] + =] + +txt[ +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 code[=s/sub[This feature makes my life easier\|/my/\|your]=] and similar. + ] +] +§[ + @title[Turing-Completeness] + txt[ +As of this version, Glyph can be considered _Turing-complete_, as it satisfies the following =>[http://c2.com/cgi/wiki?LanguageRequirementsForTuringCompleteness|requirements for Turing-completeness]: +* A conditional construct, implemented via the @condition@ macro. +* Variable assignment, by setting the value of snippets using the @snippet:@ macro and of attributes using the @attribute:@ macro. +* (infinite) iteration implemented through the new @while@ macro or recursion, which is possible thanks to the new @define:@ macro. +* 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: + ] + highlight[=html| +def:[factorial\| + ?[ + eq[{{0}}\|0]\|1\| + multiply[ + {{0}} \| factorial[subtract[{{0}}\|1]] + ] + ] +] + =] + txt[ +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: + ] + highlight[=html| +let[ + @:[a\|bits] + @:[b\|bobs] + section[ + @title[Something more about attributes] +Attributes are like lexically scoped variables. You can use them to store @[a] and @[b]. + ] +] + =] + p[Handy enough.] +] +§[ + @title[Embeddable fragments] + txt[ +Too lazy to create snippets? Feel the urge to re-use something you already wrote somewhere? Use a _fragment_ and embed it, as follows: + ] + highlight[=html| +Snippets and fragments ##[good_way\|are a good way to reuse] small chunks of content, +while the include and load macros <=[good_way] entire files. + =] + txt[...And you can also use a new @load@ macro, to embed entire files without performing any evaluation (like @include@ does).] +] +§txt[ + @title[Incompatibilities with previous versions] +To sum up: +* @snippets.yml@ is no more, define all your snippets inside your document instead. +* New "invisible space separator": @\\/@ instead of @\\.@. Because it's slightly prettier, nothing else. +* The @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 @xml/tag_name@ instead of @=tag_name@. +* No more @match@ macro, use @s/match@ instead. + +For the full list of the issues fixed in this release, see the =>[http://localhost:8080/glyph/book/changelog.html|Changelog]. + +Hope you'll enjoy this new release of Glyph. If you want to contribute, go ahead and =>[https://github.com/h3rald/glyph|fork the repo]! +] +
A content/glyph/book/styles/default.css

@@ -0,0 +1,254 @@

+* { + font-family: inherit; + border: none; + font-size: 100%; + font-style: inherit; + margin: 0; + padding: 0; } + +html { + background: #fff; } + +ol, ul { + margin: 0.3em 0; } + +p { + margin: 1em 0; } + +table { + border-collapse: collapse; + border-spacing: 0; + margin: auto; + margin-top: 1em; } + +body { + line-height: 1.2em; + margin: 0; + padding: 0; + padding: 0 1em; + text-align: justify; } + +/* Structure */ +.halftitlepage { + margin: auto; + text-align: center; } + +.titlepage { + margin: auto; + text-align: center; } + .titlepage h1 { + font-size: 2.5em; + line-height: 1.2em; + font-weight: bold; + margin-bottom: 0.2em; } + +.halftitlepage h1 { + font-size: 2.5em; + font-weight: bold; + margin-bottom: 0.2em; } +.halftitlepage h2 { + font-size: 1.1em; + font-style: italic; + font-weight: bold; + padding-top: 0; + margin-top: 0; + line-height: 2.5em; + margin-bottom: 0.5em; + prince-bookmark-level: none; } + +.titlepage h2 { + font-size: 1.1em; + font-style: italic; + font-weight: bold; + padding-top: 0; + margin-top: 0; + line-height: 2.5em; + margin-bottom: 0.5em; + prince-bookmark-level: none; } + +.author { + font-size: 1em; } + +.pubdate { + font-size: 0.8em; } + +li { + list-style-type: square; + margin: 0.4em 0; + margin-left: 1.5em; } + +ol li { + list-style-type: decimal; } + +.contents li { + list-style-type: none; } + +img { + margin: 0 5px; + padding: 2px; } + +dt { + font-weight: bold; + margin-top: 1em; } + +dd { + font-style: italic; } + +blockquote { + margin: 1em 1em; + font-style: italic; + color: #121212; } + +table { + border: 1px solid #e6e6e6; } + +th { + background: #EEE; } + +tr, td, th { + padding: 5px; } + +td, tr { + border: 1px solid #e6e6e6; } + +sup { + font-size: 0.7em; + font-weight: bold; + margin-left: -0.4em; } + +/* BLOCKS */ +.center { + margin: auto; + text-align: center; } + +.left { + margin: auto; + text-align: left; } + +.right { + margin: auto; + text-align: center; } + +code { + font-size: 0.8em; +} + +.note, .important, .tip, .caution, .box { + border: 1px solid #CCC; + display: block; + margin: 0.5em auto; + padding: 1em; + padding-top: 0em; + width: 600px; + background: #EEE; + color: #1F1F1F; } + +.note > p, .important > p, .tip > p, .caution > p { + margin: 0; + padding: 0; } + +.note-title { + font-weight: bold; + margin-right: 1em; } + +.box-title { + display: block; + text-align: center; + font-weight: bold; + font-size: 120%; + margin: 0.5em; +} + +.comment { + display: block; + border: 1px solid #004D00; + background: #7AFF7A; + padding: 3px; + margin: 1px; } + .comment .comment-pre { + color: #004D00; } + +.todo { + display: block; + border: 1px solid #990000; + background: #FF9999; + padding: 3px; + margin: 1px; } + .todo .todo-pre { + color: #990000; } + +/* TEXT */ +body { + color: #000; + font-size: 1em; } + +h2, section section h1, h1.toc-header { + display: block; + font-size: 2em; + font-weight: bold; + margin: 3em 0 1em 0; } + +h3, section section section h1 { + font-size: 1.6em; + font-weight: bold; + margin: 3em 0 1em 0; } + +h4, section section section section h1 { + font-size: 1.3em; + font-weight: bold; + margin: 3em 0 1em 0; } + +h5, section section section section section h1 { + font-size: 1.2em; + font-weight: bold; + margin: 3em 0 1em 0; } + +em { + font-style: italic; } + +a { + color: #007bc4; + text-decoration: none; } + a:hover { + color: #005b91; } + +span.line-numbers { + margin: 0; + padding: 3px; } + +nav, .navigation { + display: block; + margin: 1em auto; + text-align: center; + border: 1px solid #e6e6e6; } + +nav.contents { + margin: auto; + text-align: left; + border: none; } +nav a { + margin: 1em; } + +.navigation a { + margin: 1em; } + +nav.contents a { + margin: 0; } + +mark { + font-weight: bolder; + font-style: italic; + background: none; } + +td p, td ul, td ol { + margin: 0; } + +.topic { + margin: 2em auto; } + +/* FONTS */ +body { + font-family: 'Crimson Text', 'Palatino', 'Bookman', 'Georgia', 'Times'; } + +code, pre { + font-family: "Droid Sans Mono", "Consolas", "Monaco", "Courier", "Monospace"; }
A content/glyph/book/text_editing/macro_composition.html

@@ -0,0 +1,156 @@

+<!DOCTYPE html> +<html lang="en"> + <head> + <title>Macro Composition - Glyph</title> + <link href='http://fonts.googleapis.com/css?family=Crimson+Text:400,400italic,600,600italic,700,700italic' rel='stylesheet' type='text/css'> + + + + <meta charset="utf-8" /> + <meta name="author" content="Fabio Cevasco" /> + <meta name="copyright" content="Fabio Cevasco" /> + <meta name="robots" content="all, follow" /> + <meta name="Revisit-After" content="2 Days" /> + <meta name="language" content="en" /> + <meta name="target_country" content="en-us" /> + <meta name="country" content="United States" /> + <meta name="readability-verification" content="XmaVzRjmcFL5Bb2Fu9TZVdDKzhA3apQdxexTB2rK"/> + <meta name="description" content="H3RALD - Fabio Cevasco's Web Site" /> + + <meta name="keywords" content="h3rald, fabio cevasco, glyph" /> + <link rel="shortcut icon" href="/favicon.png" type="image/png" /> + <meta content="44.388041;9.073248" name="ICBM" /> + + <link rel="stylesheet" type="text/css" href="/styles/html5reset.css" /> + <link rel="stylesheet" type="text/css" href="/styles/style.css" /> + + <script src="http://www.google.com/jsapi?key=ABQIAAAAr6RY1Z6dchG_sX9WDLSy3xRlq2n1sm52B5HDRR5tm6o8XM18FhR56xHNNH6CsX86uN5VoTrglpyOyQ" type="text/javascript"></script> + <script src="/js/sevenup.js" type="text/javascript"></script> + <script src="/js/sevenup_black.js" type="text/javascript"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> + <script src="/js/jquery-timeago.js" type="text/javascript"></script> + <script src="/js/jquery-easing.js" type="text/javascript"></script> + <script src="/js/jquery-fancybox.js" type="text/javascript"></script> + <script src="/js/date.js" type="text/javascript"></script> + <script src="/js/feeds.js" type="text/javascript"></script> + <script src="/js/hyphenator.js" type="text/javascript"></script> + <script src="/js/init.js" type="text/javascript"></script> + <script src="/js/search.js" type="text/javascript"></script> + </head> + <body> + <section id="container"> + + <header class="page"> + <nav class="home-link"> + <a href="/"> + <img src="/images/h3rald_small.png" alt="H3RALD" class="default"/> + <![if !IE]> + <img src="/images/h3rald_hover_small.png" alt="H3RALD" class="hover"/> + <![endif]> + </a> + </nav> + + <nav class="section"> + /<a href="/glyph/" rel="glyph">GLYPH</a> + </nav> + +</header> + <article class="page glyph-book"> + <header> + <hgroup> + <h1>Macro Composition</h1> + <h2>Glyph</h2> + </hgroup> + </header> + <section id="body-text" class="hyphenate glyph-book"> + + <nav class="navigation"><a href="/glyph/book/text_editing/attribute_intro.html">Macro attributes</a> | <a href="/glyph/book/index.html">Contents</a> | <a href="/glyph/book/text_editing/esc_quot.html">Escaping and Quoting</a></nav> + <p>Glyph macros can be <em>composed</em> with other using the <code>/</code> character. Macro composition can be used instead of nesting, provided that macro containers (also called <em>dispatchers</em> in certain situations) take only one parameter and no attributes.</p> +<p>For example, the following code:</p> +<div class="CodeRay"> + <div class="code"><pre><span class="no">1</span> ?[ +<span class="no">2</span> not[output?[pdf]]| +<span class="no">3</span> ... +<span class="no">4</span> ]</pre></div> +</div> + + +<p>Can be written like this:</p> + +<div class="CodeRay"> + <div class="code"><pre><span class="no">1</span> ?[ +<span class="no">2</span> not/output?[pdf]| +<span class="no">3</span> ... +<span class="no">4</span> ]</pre></div> +</div> + + +<p>In this case, the <a href="/glyph/book/macros/macros_core.html#m_not"><code>not</code></a> macro was composed with the <a href="/glyph/book/macros/macros_core.html#m_output_"><code>output?</code></a> macro, thus removing one level of nesting.</p> +<p>Composition can be useful to simplify complex Glyph macro constructs, but also for <em>macro dispatching</em>. Currently, Glyph supports two <em>dispatchers</em>:</p> +<ul> + <li>The <a href="/glyph/book/macros/macros_core.html#m_s"><code>s</code></a> macro, used to call almost any method of the Ruby String class.</li> + <li>The <a href="/glyph/book/macros/macros_core.html#m_xml"><code>xml</code></a> macro, used to render raw <span class="caps">XML</span> tags.</li> +</ul> + <nav class="navigation"><a href="/glyph/book/text_editing/attribute_intro.html">Macro attributes</a> | <a href="/glyph/book/index.html">Contents</a> | <a href="/glyph/book/text_editing/esc_quot.html">Escaping and Quoting</a></nav> + <nav id="sharing-buttons"> +<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="h3rald">Tweet</a> +<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> +<g:plusone size="medium"></g:plusone> +<script type="text/javascript"> + (function() { + var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; + po.src = 'https://apis.google.com/js/plusone.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); + })(); +</script> +</nav> + </section> + </article> + + + <footer> + <section class="ads"> + <script type="text/javascript"><!-- + google_ad_client = "pub-2871497824158668"; + /* 728x90, created 9/10/10 */ + google_ad_slot = "3963343166"; + google_ad_width = 728; + google_ad_height = 90; + //--> + </script> + <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> + </script> + </section> + <section> + <nav> + <a href="/about/">ABOUT</a>|<a href="/contact/">CONTACT</a> + </nav> + <p>H3RALD Web Site v8.1.2 &copy; 2004 &mdash; 2011 <em>Fabio Cevasco</em></p> + </section> + </footer> + </section><!-- #container end --> + + + <!-- Start Google Analytics --> + <script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-18587377-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + </script> + <!-- End Google Analytics --> + <!-- Start of StatCounter Code --> + <script type="text/javascript"> + var sc_project=6193656; + var sc_invisible=1; + var sc_security="57f7ee2a"; + </script> + <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script> + <!-- End of StatCounter Code --> + </body> +</html>
A content/styles/_fonts.scss

@@ -0,0 +1,27 @@

+/* Fonts */ + +@font-face { + font-family: 'Crimson Text'; + src: url('../fonts/CrimsonText-Roman.otf') format('opentype'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'Crimson Text'; + src: url('../fonts/CrimsonText-Italic.otf') format('opentype'); + font-weight: normal; + font-style: italic; +} +@font-face { + font-family: 'Crimson Text'; + src: url('../fonts/CrimsonText-Bold.otf') format('opentype'); + font-weight: bold; + font-style: normal; +} +@font-face { + font-family: 'Crimson Text'; + src: url('../fonts/CrimsonText-BoldItalic.otf') format('opentype'); + font-weight: bold; + font-style: italic; +}