spf13/hugo — pull request #632 by bjornerik (2014-11-12 19:10:09+00:00)
Title: Shortcode rewrite, take 2

This commit contains a restructuring and partial rewrite of the shortcode
handling.

Prior to this commit rendering of the page content was mingled with handling
of the shortcodes. This led to several oddities.

The new flow is:

1. Shortcodes are extracted from page and replaced with placeholders. 2.
Shortcodes are processed and rendered 3. Page is processed 4. The placeholders
are replaced with the rendered shortcodes

The handling of summaries is also made simpler by this.

This also introduces the distinction between shortcodes that need further
processing and those who do not:

* `{{< >}}`: Typically raw HTML. Will not be processed.
* `{{% %}}`: Will be processed by the page's markup engine (Markdown or
(infuture) Asciidoctor)

The above also involves a new shortcode-parser, with lexical scanning inspired
by Rob Pike's talk called "Lexical Scanning in Go", which should be easier to
understand, give better error messages and perform better.

The new parser supports nested shortcodes. Two related design choices:

* If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, the
topmost shortcode is used to decide to do markdown processing or not.
* To avoid potential costly overhead of always looking far ahead for a
possible closing tag, this implementation looks at the template itself, and is
branded as a container with inner content if it contains a reference to
`.Inner`

Fixes #565 Fixes #480 Fixes #461

And probably some others.