Commit graph

115 commits

Author SHA1 Message Date
bep 55fcd2f30f 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 commit also introduces some other chenges:

1. 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.

2. If you want to exclude a shortcode from being processed (for documentation etc.), the inner part of the shorcode must be commented out, i.e. `{{%/* movie 47238zzb */%}}`. See the updated shortcode section in the documentation for further examples.

The new parser supports nested shortcodes. This isn't new, but has two related design choices worth mentioning:

* The shortcodes will be rendered individually, so If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, one will be passed through the page's markdown processor, the other 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.
2014-11-17 18:32:06 -05:00
Joel Scoble 2c51bba0c3 converted path 2 filepath 2014-11-13 22:38:21 -05:00
spf13 141f3e19e0 Migrating Hugo to Afero for filesystem calls. 2014-11-01 11:57:29 -04:00
spf13 93f3d604c6 Handlers WIP 2014-10-20 17:42:16 -04:00
spf13 5dfc1dedb8 Big refactor of how source files are used. Also added default destination extension option. 2014-10-16 20:20:09 -04:00
Austin Ziegler 9cdd2e54c2 Use md5 against the file path for uniqueness. 2014-10-07 16:45:23 -04:00
Austin Ziegler 603b24a163 Make each generated page’s footnotes unique.
If content pages are fully rendered in a list page, footnotes that use
the same reference (`[^fn]`) will have duplicated anchors. This change
builds on #526 to put the page filename (`Page.File.Name`) as part of
the anchor for a footnote.

This would fix discussion [116](http://discuss.gohugo.io/t/footnote-references-are-duplicated-on-list-pages/116).
2014-10-07 16:44:28 -04:00
Austin Ziegler e68e7ef96f Configure footnote rendering.
- The config file can provide FootnoteAnchorPrefix, which will be used
  by blackfriday when rendering to HTML. A value of `q:` has the effect
  of making the anchor for a footnote `[^footie]` be `fn:q:footie`. The
  default is `""`.

- The config file can provide FootnoteReturnLinkContents, which will be
  used by blackfriday when rendering to HTML. A value of `^` has the
  effect of making the return link be `^` instead of `[return]`.
2014-10-07 16:43:33 -04:00
Joel Scoble 4e9b04086a fix tags not being in lowercase, #491 2014-09-11 17:03:31 -04:00
Nate Finch acf9561a31 fix zero date 2014-09-08 11:55:54 -04:00
Nate Finch b97c6c7082 add Name to File, which is the filename minus the extension 2014-09-08 11:44:50 -04:00
Dave Johnston 13a317b975 Enable header id blackfriday extension 2014-08-30 14:12:53 -04:00
Joel Scoble c750a95e22 support for futre/draft summary info output 2014-08-20 14:21:15 -04:00
spf13 aae1ff3c92 Adding IsNode & IsPage functions to Page & Node 2014-08-19 21:27:13 -04:00
Andrew Jones 5969315c8f switch back to master blackfriday; enable footnotes 2014-06-30 15:14:42 -04:00
spf13 4483a6655a Centralizing the template execution logic in one place 2014-06-06 17:27:31 -04:00
spf13 4e99d6b54c Adding proper error message when view is not found.. fixing #303 2014-06-04 12:33:27 -04:00
spf13 640ab3c72e fixed #303. Adding theme support to views 2014-06-03 17:53:00 -04:00
Jake Mitchell e0ea6b9955 Support embedding <script> tags in markdown pages 2014-06-03 15:14:38 -04:00
spf13 c502f078bc Add handling for publishDates (which will be ignored if in the future). Fixed #260 2014-05-29 00:48:40 -04:00
spf13 a4a1e39a51 Fixing issue when two menu items have the same name. 2014-05-14 18:08:11 -04:00
Dato Simó 05b76dcb6f Add a blank line after the front matter when writing back a page.
Could also be done in parser.InterfaceToFrontMatter(), but logically the
extra blank line belongs to the page, not the front matter itself.
2014-05-12 15:46:58 -04:00
Vincent Batoufflet 2a902bbca6 Add Sitemaps config values handling 2014-05-09 23:11:33 -04:00
spf13 08c30b6e44 Using new helpers in page.go 2014-05-02 01:04:48 -04:00
spf13 fb7d45e613 permitting empty files again. Fixing some tests to now pass. 2014-05-01 14:11:56 -04:00
spf13 859a78e1bd Providing the ability to save (write) a content's source file. 2014-05-01 13:21:37 -04:00
spf13 1302ef9f63 Making site page initialization a bit more granular and accessible 2014-05-01 13:20:58 -04:00
spf13 cbd9506c29 moving front matter parsing (and creation) to parse package 2014-05-01 13:20:09 -04:00
spf13 bdf7cd9f9d Creating site menu configuration and have the docs site use it 2014-04-24 16:11:08 -06:00
spf13 9ecf58e29b new menus system including active link & nesting 2014-04-23 02:59:19 -04:00
spf13 69c1944f1f Add handling of deeply nested front matter 2014-04-23 02:55:43 -04:00
spf13 4a8de8ea46 Add Disqus support out of the box. Move template/bundle into hugolib. 2014-04-23 02:53:12 -04:00
spf13 c8269d6dbc Making node.Keywords the correct length 2014-04-08 21:40:03 -04:00
spf13 62dd1d45c1 Hugo config abstracted into a general purpose config library called "Viper".
Hugo casting now in own library called "cast"
2014-04-05 01:40:33 -04:00
spf13 e50b9d8ac1 Adding support for logging & verbose logging. Consolidation of error handling. Integration of jWalterWeatherman library. Fixed #137 2014-03-31 13:23:34 -04:00
Ask Bjørn Hansen 0becad727a Make error message when encountering unrecognized file extensions more helpful 2014-02-28 22:11:41 -05:00
Ask Bjørn Hansen ea8d0981d5 Make per-page url overrides take precedence over section permalink settings
This seems more reasonable to me.

I didn't understand why the pUrl comparision was on len > 2; I changed it to 0.

Closes #212.
2014-02-28 11:55:37 -05:00
spf13 14227351fa Reorganization of helpers. Centralized Url/Path logic. Fixed #175. 2014-02-27 20:33:18 -05:00
Anton Ageev 72ba6d633d Fix permalink bug in uglyurls mode (refs #187). 2014-02-02 00:56:01 -05:00
Niels Widger c1b9380dfd Add back blackfriday extensions during Markdown conversion
Modified markdownRender and markdownRenderWithTOC in hugolib/page.go to
use the same flags and extensions as were previously used when we simply
called blackfriday.MarkdownCommon to convert Markdown to HTML.  These
flags/extensions were dropped during the refactor that added the
`.TableOfContents` page variable, and caused features like Markdown
tables to no longer work.

Modified the expected output for TestTableOfContents in page_test.go,
apparently changing the flags/extensions caused an `&mdash;` to become
`&ndash;`.
2014-01-30 23:04:37 -05:00
Tibor Vass 6dd2e9a49a gofmt all go code 2014-01-29 18:03:35 -05:00
spf13 1882ffabc6 Adding support for boolean params 2014-01-28 23:24:59 -05:00
spf13 1da3fd039a Continue with TOC integration and page refactor. Updated a few tests to match new generated output. 2014-01-28 23:11:05 -05:00
spf13 9666f33e2f Don’t render short codes on summary twice 2014-01-27 17:32:36 -05:00
spf13 d0825a211a Big refactor of pages code. Changed TOC code to only parse when actually used 2014-01-27 17:20:20 -05:00
Niels Widger f62e3e9940 Add new TableOfContents Page variable (Markdown only)
Added TableOfContents field to hugolib.Page struct.  New function
getTableOfContents is used in convertMarkdown to set the TableOfContents
field.

Added new test file hugolib/page_toc_test.go with a simple test of the
new functionality.

Conflicts:
	hugolib/page.go
2014-01-23 17:27:08 -05:00
spf13 3851117c25 renaming MinRead to ReadingTime and adding to documentation. 2014-01-21 20:08:24 -05:00
spf13 065928fcf0 Adding page sorting by weight function (the default) 2013-12-28 12:56:12 -05:00
spf13 70745e8cb5 Complete refactor of indexes, move (and rewrite) page sorting to page.go, add tests 2013-12-20 09:10:05 -05:00
spf13 0e04b9a029 Moving processing short codes to the page 2013-12-06 23:57:24 -05:00