fix: changing terminal yaml line, generalizing forematter splitting
authortycho garen <garen@tychoish.com>
Sun, 7 Jul 2013 14:01:53 +0000 (10:01 -0400)
committertycho garen <garen@tychoish.com>
Sun, 7 Jul 2013 14:01:53 +0000 (10:01 -0400)
16 files changed:
docs/content/doc/configuration.md
docs/content/doc/contributing.md
docs/content/doc/contributors.md
docs/content/doc/example.md
docs/content/doc/front-matter.md
docs/content/doc/installing.md
docs/content/doc/license.md
docs/content/doc/organization.md
docs/content/doc/release-notes.md
docs/content/doc/roadmap.md
docs/content/doc/shortcodes.md
docs/content/doc/source-directory.md
docs/content/doc/templates.md
docs/content/doc/usage.md
docs/content/doc/variables.md
hugolib/page.go

index 670a8e994f21a1545b69f98e7c6fa3c56c401736..09cfb48f3a5d0ac07d6759bf5e43e8b4dc6f1e97 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Configuring Hugo"
 pubdate: "2013-07-01"
----
+...
 
 The directory structure and templates provide the majority of the
 configuration for a site. In fact a config file isn't even needed for many websites
index 6ddb241f1b88083242a0fb965947e9c92ff24c98..6b8aa82333cc6da2f5590797478adc66218496cd 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Contributing to Hugo"
 Pubdate: "2013-07-01"
----
+...
 
 1. Fork it from https://github.com/spf13/hugo
 2. Create your feature branch (`git checkout -b my-new-feature`)
index 3a7d7e647d35418d6248f1a6838bcf611ecfed37..e8a8ad976144027537b8024102c7951c99dcfa95 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Contributors"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo was built with love and golang by:
 
index 51e3c160e04a73a99c89b64946032a4bd8bcaa5f..b13fa3e16b906227678cef0e61873d8b7c0192c5 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Example Content File"
 Pubdate: "2013-07-01"
----
+...
 
 Somethings are better shown than explained. The following is a very basic example of a content file:
 
index e4342099fcc0839f13ab6ff0a05dbec45789f387..af930b25f86581d4f5f216052aee4e03688adf57 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Front Matter"
 Pubdate: "2013-07-01"
----
+...
 
 The front matter is one of the features that gives Hugo it's strength. It enables
 you to include the meta data of the content right with it. Hugo supports a few 
@@ -16,7 +16,7 @@ different formats. The main format supported is YAML. Here is an example:
       - "Development"
       - "VIM"
     Slug: "spf13-vim-3-0-release-and-new-website"
-    ---
+    ...
 
 ### Variables
 
index 92a07dec94752d3f74c4dacc96009897e28b0a29..1f0f02dedcb2b5b5b6dc471f29a3fa3e58639324 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Installing Hugo"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo is written in GoLang with support for Windows, Linux, FreeBSD and OSX.
 
index 613a7ed27e030e3556752b727c5849c7fc548dac..43eba11e69bc1f9ba64e125419a5217b83329260 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "License"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo is released under the Simple Public License.
 
index f524c59d0c38e3ec709ea49580e0cacdc6fa8a32..23238b26d70011c1800f70c2a22f213b73ab33af 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Organization"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization
 that you provide for your content to minimize any extra configuration, though this can be overridden
index e268a5c3e1ca84abed8ccefd21f6f240ac9eb140..a4b9e11e5744423f660bf57d400497bf0ce5c2e5 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Release Notes"
 Pubdate: "2013-07-01"
----
+...
 
 * **0.7.0** July 4, 2013
   * Hugo now includes a simple server
index 93a7a83d40f25399a4e4bcaa6085db65632fb39a..7cc5bc812fc8b446133aa474d2e0b9ce2b313e8f 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Roadmap"
 Pubdate: "2013-07-01"
----
+...
 
 In no particular order, here is what I'm working on:
 
index 222963b03ffb2168ccb64c3781b070a49dd02ee4..abca668feb2626dbfc822f6602fe6065e9ab329b 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Shortcodes"
 Pubdate: "2013-07-01"
----
+...
 
 Because Hugo uses markdown for it's content format, it was clear that there's a lot of things that 
 markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it.
index 9b0d1ae7e53c123153d94daeb26b8254a90188c6..a33adb279cca911970bd3a782769816ad75e551c 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Source Directory Organization"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo takes a single directory and uses it as the input for creating a complete website.
 
index 6b6e0f34c5fc9dbe899d42efa6a2586413f02b67..c2164feb8d864750d29e403a17ce45c6e836410c 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Templates"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo uses the excellent golang html/template library for it's template engine. It is an extremely
 lightweight engine that provides a very small amount of logic. In our 
index 772c1039453c36fda4dfef18a2d97a98e4a4c885..950c4abc8436e2279df907a48fb5d30f4c0399c6 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Using Hugo"
 Pubdate: "2013-07-01"
----
+...
 
 Make sure either hugo is in your path or provide a path to it.
 
index 8a80fa175b486293b54a4a5ff6f40308bdb10972..a5d70739ba68eff39ac3be8fc456caa33c09534e 100644 (file)
@@ -1,7 +1,7 @@
 ---
 title: "Variables"
 Pubdate: "2013-07-01"
----
+...
 
 Hugo makes a set of values available to the templates. Go templates are context based. The following
 are available in the context for the templates.
index b0e796e97166bc468376318a368643310d916392..c27bb7c54d26a8750d6256746cccc0a7db216a0b 100644 (file)
@@ -148,62 +148,44 @@ func (p *Page) analyzePage() {
 func (page *Page) parseYamlMetaData(data []byte) ([]string, error) {
        var err error
 
-       lines := strings.Split(string(data), "\n")
-       datum := lines[0:]
-
-       // go through content parse between "---" and "..."
-       // must be on their own lines (for now)
-       var found = 0
-       for i, line := range lines {
-
-               if strings.HasPrefix(line, "---") {
-                       found += 1
-               }
-
-               if strings.HasPrefix(line, "---") {
-                       found -= 1
-               }
-
-               if found == 0 {
-                       datum = lines[1: i+2]
-                       lines = lines[i+3:]
-                       break
-               }
-       }
+       datum, lines := splitPageContent(data, "---", "...")
 
        err = page.handleMetaData(page.handleYamlMetaData([]byte(strings.Join(datum, "\n"))))
        return lines, err
 }
 
+
 func (page *Page) parseJsonMetaData(data []byte) ([]string, error) {
        var err error
 
+       datum, lines := splitPageContent(data, "{", "}")
+
+       err = page.handleMetaData(page.handleJsonMetaData([]byte(strings.Join(datum, "\n"))))
+       return lines, err
+}
+
+func splitPageContent(data []byte, start string, end string) ([]string, []string) {
        lines := strings.Split(string(data), "\n")
        datum := lines[0:]
 
-       // go through content parse between "{" and "}"
-       // must be on their own lines (for now)
        var found = 0
        for i, line := range lines {
-               line = strings.TrimSpace(line)
 
-               if line == "{" {
+               if strings.HasPrefix(line, start) {
                        found += 1
                }
 
-               if line == "}" {
+               if strings.HasPrefix(line, end) {
                        found -= 1
                }
 
                if found == 0 {
-                       datum = lines[: i+1]
+                       datum = lines[1: i+1]
                        lines = lines[i+1:]
                        break
                }
        }
-
-       err = page.handleMetaData(page.handleJsonMetaData([]byte(strings.Join(datum, "\n"))))
-       return lines, err
+       return datum, lines
 }
 
 func (p *Page) Permalink() template.HTML {