Commit graph

49 commits

Author SHA1 Message Date
Naoya Inada
407e80a9ab Add site-wide/per-page [blackfriday] extensions option 2015-01-26 09:55:37 +01:00
Anthony Fok
803865f870 Fix for page.GetParam() for JSON and TOML maps
Setting per-page Blackfriday angledQuotes did not work
with TOML or JSON front matter, but it does work with YAML.

It turns out that page.Params("blackfriday") returns
type map[interface{}]interface{} for YAML, but
type map[string]interface{} for JSON and TOML.

This patch updates page.GetParam() to catch the latter,
with an error message if page.GetParam() does not recognize
a type.  A test is also added.
2015-01-24 15:25:44 +01:00
Tatsushi Demachi
78e9229c52 Fix "hugo new" EOF error with an archetype file without the final EOL
This rewrites `extractFrontMatterDelims` function to make it work with
an archetype file without the final EOL and adds more detailed error
messages and comments.

It also removes `matches` and `matches_quick` functions which aren't
called anywhere.
2015-01-10 19:48:35 +01:00
bep
9f77f93071 Fix various Windows-issues
File handling was broken on Windows. This commit contains a revision of the path handling with separation of file paths and urls where needed.

There may be remaining issues and there may be better ways to do this, but it is easier to start that refactoring job with a set of passing tests.

Fixes #687
Fixes #660
2014-12-09 09:43:15 -05:00
Austin Ziegler
8f9cea7f58 Enable descriptive header IDs.
Enable blackfriday.EXTENSION_AUTO_HEADER_IDS to generate the name of the
header ID from the text in the header. Works for prefix and underline
headers.

- TOC extraction had to be modified to look for `<li><a href="#`>
  instead of `#toc_` because of this change.
- Fixed a number of tests that depended on the presence of `toc_` with
  as an `id` or as a `href` value.
- Renames the earlier parameter `footnoteref` to `documentId` as it more
  accurately represents the nature of the parameter. The `documentId` is
  appended to all generated headers through the new HTML renderer
  parameter `HeaderIDSuffix`.
2014-11-24 18:01:57 -05:00
spf13
4a2f16f91e refactor handlers to use types instead of structs. 2014-11-20 12:43:34 -05:00
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
5dfc1dedb8 Big refactor of how source files are used. Also added default destination extension option. 2014-10-16 20:20:09 -04:00
Joel Scoble
4b9e4c90d9 #462 fix, remove leading and trailing dashes from urlized slug. includes test changes 2014-10-07 17:05:11 -04:00
Joel Scoble
4e9b04086a fix tags not being in lowercase, #491 2014-09-11 17:03:31 -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
fb7d45e613 permitting empty files again. Fixing some tests to now pass. 2014-05-01 14:11:56 -04:00
Mike Keesey
2540d884d8 Fixing issues go vet reports. 2014-03-01 09:56:17 -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
f45c6bc38a Moved TOC test into page_test. Some general page_test cleanup. 2014-01-28 23:09:24 -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
spf13
3851117c25 renaming MinRead to ReadingTime and adding to documentation. 2014-01-21 20:08:24 -05:00
spf13
8055838c70 Allowing empty files (ignored) so you can touch a new file while watching 2013-12-28 13:47:34 -05:00
spf13
f432b187a0 render shortcodes prior to converting to html 2013-12-06 23:32:00 -05:00
Phil Pennock
40d05f12a7 Truncated; .Site.Params; First function
* Add `.Truncated` bool to each page; will be set true if the
  `.Summary` is truncated and it's worth showing a "more" link of some
  kind.
* Add `Params` to the site config, defining `.Site.Params` accessible
  to each page; this lets the site maintainer associate arbitrary data
  with names, on a site-wide basis.
* Provide a `First` function to templates:
  * Use-case: `{{range First 5 .Site.Recent}}` or anything else which
    is a simple iterable provided by hugolib
* Tests by me for `.Truncated` and `First`

Also @noahcampbell contributed towards this:

* Add UnitTest for `.Site.Params`:
> Digging into this test case a bit more, I'm realizing that we need
> to create a param test case to ensure that for each type we render
> (page, index, homepage, rss, etc.) that the proper fields are
> represented.  This will help us refactor without fear in the
> future.

Sample config.yaml:

```yaml
title: "Test site"
params:
  Subtitle: "More tests always good"
  AuthorName: "John Doe"
  SidebarRecentLimit: 5
```

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-12 22:49:54 +00:00
spf13
f3c816eabd Adding support for more front matter types (int, float & date) 2013-10-24 14:31:04 -07:00
spf13
4263094d75 Adding support for MinRead. Closed #106 2013-10-15 09:32:21 -04:00
spf13
be5ace1588 Wordcount restored. fixed #92 2013-10-15 09:15:52 -04:00
Noah Campbell
9500ec1b6b Refactor layout selection code
The render code path would use a fallback if there was an exception.
This change instead relies on explicit declaration of the layout to use
and includes a check to see if the layout indeed exists before
attempting to render it.
2013-10-08 18:44:15 +02:00
spf13
266f583a8c Restoring former snippet behavior & adding test to ensure future behavior 2013-10-04 12:28:28 -04:00
spf13
18f2b82658 Switching to the rjson library which is more friendly to human generated json. 2013-10-01 22:45:24 -04:00
Noah Campbell
311e102223 Allow non-markdown content in content directory
Allow content that is not markdown and does not need to be rendered to
exists in the content directory.  Currently any valid html or xml
document can exist.  Templates are applied to these documents as well.
If you need to have content that doesn't have templates or AbsUrlify
like operations, then continue to put this content in static and it will
be copied over.
2013-09-18 14:21:27 -07:00
Noah Campbell
67b2abaf09 Add IsRenderable to Page
As pages are read from the target, they will be assessed if they should
be rendered or not.  The logic for IsRenderable is in the parser/page.go
and looks for anything exception '<'.
2013-09-18 10:17:43 -07:00
Noah Campbell
d8e1834910 Fix parsing edge case of frontmatter
When the frontmatter contains a - (or other delimiter) close to the
closing frontmatter delimiter, frontmatter detection would fail.
2013-09-18 09:15:46 -07:00
Noah Campbell
a82efe5bb1 Merge remote-tracking branch 'origin/parser' into mrg_praser
Also brought in parse for github.com/noahcampbell/akebia

Conflicts:
	hugolib/page.go
	hugolib/page_test.go
2013-09-17 15:52:40 -07:00
Noah Campbell
74b55fc7c8 Normalize paths within hugo
filepath was used inconsistently throughout the hugolib.  With the
introduction of source and target modules, all path are normalized to
"/".  This simplifies the processing of paths.  It does mean that
contributors need to be aware of using path/filepath in any module other
than source or target is not recommended.  The current exception is
hugolib/config.go
2013-09-12 10:48:59 -07:00
Noah Campbell
d4d9da9f3a Remove page module dependence on opening files
The site is responsible for reading files, page only operates on
buffers.
2013-09-04 19:36:06 -07:00
Noah Campbell
79d9f82e79 Code reorg, helpers.go has been decomposed.
It started with wanting to move templates in template bundles and the
rest followed.  I did my best to start grouping related functions
together, but there are some that I missed.  There is also the method
Urlize that seems to be a special function used in both worlds.  I'll
need to revisit this method.
2013-09-03 16:16:07 -07:00
Noah Campbell
207d8fb7af Date rendering unit tests in pages
Tests to ensure rendering dates in templates is working correctly.
Actually, I was running into invalid templates not giving warnings when
I was trying to render a date.
2013-09-03 14:51:06 -07:00
Noah Campbell
3ecc698f5e Remove hugolib.HTML and hugolib.URL types
These types were not be rendered correctly by the html/template package.
Removing them gets the correct behavior.

Fixes #74
2013-09-03 12:43:56 -07:00
Fabrizio (Misto) Milo
ba82a20321 Add support for amber files
If a layout file ends with .amber it will interpreted as a Amber file

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:32 -07:00
Fabrizio (Misto) Milo
ee5865f239 Abstract html/template dependency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:27 -07:00
Mark Sanborn
6c8e7edbb4 The <!--more--> (summary divider) now works even if it is on the same line as content
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 07:44:29 -07:00
Noah Campbell
bc3c229002 Ensure Section is set before returning Page object. 2013-08-30 20:13:22 -07:00
Noah Campbell
554375b2ad Using new parser. 2013-08-25 20:27:03 -07:00
Ross Lawley
9930011ea2 Wordpress summaries
Allow full control of summaries which can be rendered as html rather
than text.  Using a `<!--more-->` html comment in your markdown / rst
you can indiciate where the summary should end and have the summary
converted to html.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>

Conflicts:
	hugolib/page_test.go
2013-08-23 16:46:19 -07:00
Noah Campbell
599e6672f7 Removing GetSection
Using GetXXX is not idiomatic to Go.  Also added a bunch of unit testing
around this method.
2013-08-23 14:14:54 -07:00
spf13
480e01eb15 Further work on path/section stuff. Tests passing now. 2013-08-14 08:57:14 -04:00
Noah Campbell
e26b43f6d9 Adding more test cases 2013-08-09 17:36:32 -07:00
Noah Campbell
085ce15f7c Adding ability to read from io.Reader
This allows for testing without relying on the file system.  Parsing algorithm to not read the entire file into memory.
2013-08-09 17:36:32 -07:00