diff --git a/docs/content/content/archetypes.md b/docs/content/content/archetypes.md index d3338c1d7..05269d384 100644 --- a/docs/content/content/archetypes.md +++ b/docs/content/content/archetypes.md @@ -29,10 +29,12 @@ We will use ‘tags’ and ‘categories’ for our taxonomies, so let's create #### archetypes/default.md - +++ - tags = ["x", "y"] - categories = ["x", "y"] - +++ +```toml ++++ +tags = ["x", "y"] +categories = ["x", "y"] ++++ +``` > __CAVEAT:__ Some editors (e.g. Sublime, Emacs) do not insert an EOL (end-of-line) character at the end of the file (i.e. EOF). If you get a [strange EOF error](/troubleshooting/strange-eof-error/) when using `hugo new`, please open each archetype file (i.e. `archetypes/*.md`) and press Enter to type a carriage return after the closing `+++` or `---` as necessary. @@ -47,12 +49,14 @@ Hugo would create the file with the following contents: #### content/post/my-new-post.md - +++ - title = "my new post" - date = "2015-01-12T19:20:04-07:00" - tags = ["x", "y"] - categories = ["x", "y"] - +++ +```toml ++++ +title = "my new post" +date = "2015-01-12T19:20:04-07:00" +tags = ["x", "y"] +categories = ["x", "y"] ++++ +``` We see that the `title` and `date` variables have been added, in addition to the `tags` and `categories` variables which were carried over from `archetype/default.md`. @@ -64,11 +68,13 @@ Earlier you created a new content type by adding a new subfolder to the content #### archetypes/musician.md - +++ - name = "" - bio = "" - genre = "" - +++ +```toml ++++ +name = "" +bio = "" +genre = "" ++++ +``` Now let's create a new musician. @@ -78,13 +84,15 @@ This time, Hugo recognizes the custom archetype and uses it instead of the defau #### content/musician/mozart.md - +++ - title = "mozart" - date = "2015-08-24T13:04:37+02:00" - name = "" - bio = "" - genre = "" - +++ +```toml ++++ +title = "mozart" +date = "2015-08-24T13:04:37+02:00" +name = "" +bio = "" +genre = "" ++++ +``` ## Using a different front matter format diff --git a/docs/content/content/example.md b/docs/content/content/example.md index 20d07c469..43727c69b 100644 --- a/docs/content/content/example.md +++ b/docs/content/content/example.md @@ -6,9 +6,9 @@ linktitle: Example menu: main: parent: content +prev: /content/summaries next: /themes/overview notoc: true -prev: /content/summaries title: Example Content File weight: 70 --- @@ -19,8 +19,7 @@ Some things are better shown than explained. The following is a very basic examp With TOML front matter: -```markdown -+++ +
+++
 date        = "2013-06-21T11:27:27-04:00"
 title       = "Nitro: A quick and simple profiler for Go"
 description = "Nitro is a simple profiler for your Golang applications"
@@ -29,8 +28,7 @@ topics      = [ "Development", "Go" ]
 slug        = "nitro"
 project_url = "https://github.com/spf13/nitro"
 +++
-
-# Nitro
+# Nitro
 
 Quick and easy performance analyzer library for [Go](http://golang.org/).
 
@@ -48,11 +46,11 @@ of the library.
     $ go get github.com/spf13/nitro
 
 Next, include nitro in your application.
-```
+
You may also use the equivalent YAML front matter: -```markdown +```yaml --- date: "2013-06-21T11:27:27-04:00" title: "Nitro: A quick and simple profiler for Go" diff --git a/docs/content/content/front-matter.md b/docs/content/content/front-matter.md index 8d82fd958..4bf75f058 100644 --- a/docs/content/content/front-matter.md +++ b/docs/content/content/front-matter.md @@ -28,50 +28,54 @@ Supported formats: ## TOML Example - +++ - title = "spf13-vim 3.0 release and new website" - description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." - tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ] - date = "2012-04-06" - categories = [ - "Development", - "VIM" - ] - slug = "spf13-vim-3-0-release-and-new-website" - +++ - - Content of the file goes Here +
+++
+title = "spf13-vim 3.0 release and new website"
+description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
+tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
+date = "2012-04-06"
+categories = [
+  "Development",
+  "VIM"
+]
+slug = "spf13-vim-3-0-release-and-new-website"
++++
+Content of the file goes Here
+
## YAML Example - --- - title: "spf13-vim 3.0 release and new website" - description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." - tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ] - date: "2012-04-06" - categories: - - "Development" - - "VIM" - slug: "spf13-vim-3-0-release-and-new-website" - --- - - Content of the file goes Here +```yaml +--- +title: "spf13-vim 3.0 release and new website" +description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim." +tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ] +date: "2012-04-06" +categories: + - "Development" + - "VIM" +slug: "spf13-vim-3-0-release-and-new-website" +--- + +Content of the file goes Here +``` ## JSON Example - { - "title": "spf13-vim 3.0 release and new website", - "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.", - "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ], - "date": "2012-04-06", - "categories": [ - "Development", - "VIM" - ], - "slug": "spf13-vim-3-0-release-and-new-website", - } - - Content of the file goes Here +```json +{ + "title": "spf13-vim 3.0 release and new website", + "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.", + "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ], + "date": "2012-04-06", + "categories": [ + "Development", + "VIM" + ], + "slug": "spf13-vim-3-0-release-and-new-website", +} + +Content of the file goes Here +``` ## Variables diff --git a/docs/content/content/ordering.md b/docs/content/content/ordering.md index 07600b34d..cf00eaea7 100644 --- a/docs/content/content/ordering.md +++ b/docs/content/content/ordering.md @@ -26,13 +26,14 @@ guaranteed. ## Assigning weight to content - +++ - weight = 4 - title = "Three" - date = "2012-04-06" - +++ - Front Matter with Ordered Pages 3 - +```toml ++++ +weight = 4 +title = "Three" +date = "2012-04-06" ++++ +Front Matter with Ordered Pages 3 +``` ## Ordering Content Within Taxonomies diff --git a/docs/content/content/sections.md b/docs/content/content/sections.md index 03002a42f..979edf70b 100644 --- a/docs/content/content/sections.md +++ b/docs/content/content/sections.md @@ -17,17 +17,17 @@ uses the top level of your content organization as **the Section**. The following example site uses two sections, "post" and "quote". - . - └── content - ├── post - | ├── firstpost.md // <- http://1.com/post/firstpost/ - | ├── happy - | | └── ness.md // <- http://1.com/post/happy/ness/ - | └── secondpost.md // <- http://1.com/post/secondpost/ - └── quote - ├── first.md // <- http://1.com/quote/first/ - └── second.md // <- http://1.com/quote/second/ - +{{< nohighlight >}}. +└── content + ├── post + | ├── firstpost.md // <- http://1.com/post/firstpost/ + | ├── happy + | | └── ness.md // <- http://1.com/post/happy/ness/ + | └── secondpost.md // <- http://1.com/post/secondpost/ + └── quote + ├── first.md // <- http://1.com/quote/first/ + └── second.md // <- http://1.com/quote/second/ +{{< /nohighlight >}} ## Section Lists diff --git a/docs/content/extras/aliases.md b/docs/content/extras/aliases.md index 885abc967..7e2c6ef31 100644 --- a/docs/content/extras/aliases.md +++ b/docs/content/extras/aliases.md @@ -27,7 +27,7 @@ Given a post on your current Hugo site, with a path of: ### TOML frontmatter -~~~yaml +```toml +++ ... aliases = [ @@ -36,11 +36,11 @@ aliases = [ ] ... +++ -~~~ +``` ### YAML frontmatter -~~~yaml +```yaml --- ... aliases: @@ -48,15 +48,15 @@ aliases: - /2010/01/01/even-earlier-url.html ... --- -~~~ +``` Now when you visit any of the locations specified in aliases, _assuming the same site domain_, you'll be redirected to the page they are specified on. ## Important Behaviors 1. *Hugo makes no assumptions about aliases. They also don't change based -on your UglyURLs setting. You need to provide absolute path to your webroot and the -complete filename or directory.* +on your UglyURLs setting. You need to provide absolute path to your webroot +and the complete filename or directory.* 2. *Aliases are rendered prior to any content and will be overwritten by any content with the same location.* @@ -67,7 +67,7 @@ When aliases are specified, Hugo creates a physical folder structure to match th Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like: -~~~html +```html @@ -76,6 +76,6 @@ Assuming a baseurl of `mysite.tld`, the contents of the html file will look some -~~~ +``` The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case. diff --git a/docs/content/extras/crossreferences.md b/docs/content/extras/crossreferences.md index 0b37cc09c..d80340629 100644 --- a/docs/content/extras/crossreferences.md +++ b/docs/content/extras/crossreferences.md @@ -14,12 +14,14 @@ Hugo makes it easy to link documents together with the `ref` and `relref` shortc ## Using `ref` and `relref` - {{}} - {{}} - {{}} - {{}} - {{}} - {{}} +```django +{{}} +{{}} +{{}} +{{}} +{{}} +{{}} +``` The single parameter to `ref` is a string with a content _document name_ (`about.md`), an in-document _anchor_ (`#who`), or both (`about.md#who`). diff --git a/docs/content/overview/usage.md b/docs/content/overview/usage.md index 9619c0a53..4b002457a 100644 --- a/docs/content/overview/usage.md +++ b/docs/content/overview/usage.md @@ -14,7 +14,7 @@ weight: 30 Make sure either `hugo` is in your `PATH` or provide a path to it. -
$ hugo help
+{{< nohighlight >}}$ hugo help
 
 Hugo is a Fast and Flexible Static Site Generator built with love by spf13 and friends in Go.
 
@@ -65,20 +65,21 @@ Additional help topics:
  hugo convert         Convert will modify your content to different formats hugo list            Listing out various types of content
 
 Use "hugo help [command]" for more information about a command.
-
+{{< /nohighlight >}} ## Common Usage Example The most common use is probably to run `hugo` with your current directory being the input directory: - $ hugo - 0 draft content - 0 future content - 99 pages created - 0 paginator pages created - 16 tags created - 0 groups created - in 120 ms +{{< nohighlight >}}$ hugo +0 draft content +0 future content +99 pages created +0 paginator pages created +16 tags created +0 groups created +in 120 ms +{{< /nohighlight >}} This generates your web site to the `public/` directory, ready to be deployed to your web server. @@ -89,34 +90,36 @@ ready to be deployed to your web server. If you are working on things and want to see the changes immediately, tell Hugo to watch for changes. Hugo will watch the filesystem for changes, and rebuild your site as soon as a file is saved: - $ hugo -s ~/Code/hugo/docs - 0 draft content - 0 future content - 99 pages created - 0 paginator pages created - 16 tags created - 0 groups created - in 120 ms - Watching for changes in /Users/spf13/Code/hugo/docs/content - Press Ctrl+C to stop +{{< nohighlight >}}$ hugo -s ~/Code/hugo/docs +0 draft content +0 future content +99 pages created +0 paginator pages created +16 tags created +0 groups created +in 120 ms +Watching for changes in /Users/spf13/Code/hugo/docs/content +Press Ctrl+C to stop +{{< /nohighlight >}} Hugo can even run a server and create a site preview at the same time! Hugo implements [LiveReload](/extras/livereload/) technology to automatically reload any open pages in all JavaScript-enabled browsers, including mobile. This is the easiest and most common way to develop a Hugo web site: - $ hugo server -ws ~/Code/hugo/docs - 0 draft content - 0 future content - 99 pages created - 0 paginator pages created - 16 tags created - 0 groups created - in 120 ms - Watching for changes in /Users/spf13/Code/hugo/docs/content - Serving pages from /Users/spf13/Code/hugo/docs/public - Web Server is available at http://localhost:1313/ - Press Ctrl+C to stop +{{< nohighlight >}}$ hugo server -ws ~/Code/hugo/docs +0 draft content +0 future content +99 pages created +0 paginator pages created +16 tags created +0 groups created +in 120 ms +Watching for changes in /Users/spf13/Code/hugo/docs/content +Serving pages from /Users/spf13/Code/hugo/docs/public +Web Server is available at http://localhost:1313/ +Press Ctrl+C to stop +{{< /nohighlight >}} ## Deploying your web site @@ -151,11 +154,13 @@ An easy way to work around this is to use different directories for development To start a server that builds draft content (helpful for editing), you can specify a different destination: the `dev/` dir. - $ hugo server -wDs ~/Code/hugo/docs -d dev +{{< nohighlight >}}$ hugo server -wDs ~/Code/hugo/docs -d dev +{{< /nohighlight >}} When the content is ready for publishing, use the default `public/` dir: - $ hugo -s ~/Code/hugo/docs +{{< nohighlight >}}$ hugo -s ~/Code/hugo/docs +{{< /nohighlight >}} This prevents content you're not ready to share yet from accidentally becoming available. @@ -170,9 +175,11 @@ No other web server software (Apache, nginx, IIS...) is necessary. Here is the command: - $ hugo server --baseURL=http://yoursite.org/ --port=80 \ - --appendPort=false \ - --bind=87.245.198.50 +{{< nohighlight >}}$ hugo server --baseURL=http://yoursite.org/ \ + --port=80 \ + --appendPort=false \ + --bind=87.245.198.50 +{{< /nohighlight >}} Note the `bind` option, which is the interface to which the server will bind (defaults to `127.0.0.1`, which is fine for most development use cases). Some hosts, like Amazon WS, runs network address translation and it can sometimes be hard to figure out the actual IP address. Using `--bind=0.0.0.0` will bind to all interfaces. diff --git a/docs/content/taxonomies/methods.md b/docs/content/taxonomies/methods.md index d7a3bc3fa..10f5d7b40 100644 --- a/docs/content/taxonomies/methods.md +++ b/docs/content/taxonomies/methods.md @@ -16,39 +16,53 @@ Hugo makes a set of values and methods available on the various Taxonomy structu A Taxonomy is a `map[string]WeightedPages`. -**.Get(term)** Returns the WeightedPages for a term.
-**.Count(term)** The number of pieces of content assigned to this term.
-**.Alphabetical** Returns an OrderedTaxonomy (slice) ordered by Term.
-**.ByCount** Returns an OrderedTaxonomy (slice) ordered by number of entries.
+.Get(term) +: Returns the WeightedPages for a term. + +.Count(term) +: The number of pieces of content assigned to this term. + +.Alphabetical +: Returns an OrderedTaxonomy (slice) ordered by Term. + +.ByCount +: Returns an OrderedTaxonomy (slice) ordered by number of entries. ## OrderedTaxonomy Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order. - []struct { - Name string - WeightedPages WeightedPages - } +```go +[]struct { + Name string + WeightedPages WeightedPages +} +``` Each element of the slice has: -**.Term** The Term used.
-**.WeightedPages** A slice of Weighted Pages.
-**.Count** The number of pieces of content assigned to this term.
-**.Pages** All Pages assigned to this term. All [list methods](/templates/list/) are available to this.
+.Term +: The Term used. + +.WeightedPages +: A slice of Weighted Pages. + +.Count +: The number of pieces of content assigned to this term. + +.Pages +: All Pages assigned to this term. All [list methods](/templates/list/) are available to this. ## WeightedPages WeightedPages is simply a slice of WeightedPage. - type WeightedPages []WeightedPage - -**.Count(term)** The number of pieces of content assigned to this term.
-**.Pages** Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/).
- - - - - +```go +type WeightedPages []WeightedPage +``` +.Count(term) +: The number of pieces of content assigned to this term. +.Pages +: Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/). diff --git a/docs/content/taxonomies/ordering.md b/docs/content/taxonomies/ordering.md index c1799864f..d1e6a9e89 100644 --- a/docs/content/taxonomies/ordering.md +++ b/docs/content/taxonomies/ordering.md @@ -57,15 +57,16 @@ When iterating over content within taxonomies the default sort is first by weigh Content can be assigned weight for each taxonomy that it's assigned to. - +++ - tags = [ "a", "b", "c" ] - tags_weight = 22 - categories = ["d"] - title = "foo" - categories_weight = 44 - +++ - Front Matter with weighted tags and categories - +```toml ++++ +tags = [ "a", "b", "c" ] +tags_weight = 22 +categories = ["d"] +title = "foo" +categories_weight = 44 ++++ +Front Matter with weighted tags and categories +``` The convention is `taxonomyname_weight`. diff --git a/docs/content/taxonomies/usage.md b/docs/content/taxonomies/usage.md index 963daf9dc..35ba3d63e 100644 --- a/docs/content/taxonomies/usage.md +++ b/docs/content/taxonomies/usage.md @@ -30,10 +30,10 @@ or singular key: "plural value" -
[taxonomies]
-  tag = "tags"
-  category = "categories"
-  series = "series"
+
[taxonomies]
+tag = "tags"
+category = "categories"
+series = "series"
 
taxonomies:
   tag: "tags"
@@ -69,31 +69,35 @@ you will need to pass the taxonomy values through the `urlize` template function
 
 ### Front Matter Example (in TOML)
 
-    +++
-    title = "Hugo: A fast and flexible static site generator"
-    tags = [ "Development", "Go", "fast", "Blogging" ]
-    categories = [ "Development" ]
-    series = [ "Go Web Dev" ]
-    slug = "hugo"
-    project_url = "https://github.com/spf13/hugo"
-    +++
+```toml
++++
+title = "Hugo: A fast and flexible static site generator"
+tags = [ "Development", "Go", "fast", "Blogging" ]
+categories = [ "Development" ]
+series = [ "Go Web Dev" ]
+slug = "hugo"
+project_url = "https://github.com/spf13/hugo"
++++
+```
 
 ### Front Matter Example (in JSON)
 
-    {
-        "title": "Hugo: A fast and flexible static site generator",
-        "tags": [
-            "Development",
-            "Go",
-            "fast",
-            "Blogging"
-        ],
-        "categories" : [
-            "Development"
-        ],
-        "series" : [
-            "Go Web Dev"
-        ],
-        "slug": "hugo",
-        "project_url": "https://github.com/spf13/hugo"
-    }
+```json
+{
+    "title": "Hugo: A fast and flexible static site generator",
+    "tags": [
+        "Development",
+        "Go",
+        "fast",
+        "Blogging"
+    ],
+    "categories" : [
+        "Development"
+    ],
+    "series" : [
+        "Go Web Dev"
+    ],
+    "slug": "hugo",
+    "project_url": "https://github.com/spf13/hugo"
+}
+```
diff --git a/docs/content/templates/functions.md b/docs/content/templates/functions.md
index 1e293a88c..29f265832 100644
--- a/docs/content/templates/functions.md
+++ b/docs/content/templates/functions.md
@@ -51,8 +51,8 @@ e.g.
     // Outputs Tags: tag1, tag2 and tag3
 
 ### dict
-Creates a dictionary (map[string, interface{}), expects parameters added in value:object fasion.
-Invalid combinations like keys that are not strings or uneven number of parameters, will result in an exception thrown
+Creates a dictionary `(map[string, interface{})`, expects parameters added in value:object fasion.
+Invalid combinations like keys that are not strings or uneven number of parameters, will result in an exception thrown.
 Useful for passing maps to partials when adding to a template.
 
 e.g. Pass into "foo.html" a map with the keys "important, content" 
@@ -369,7 +369,7 @@ e.g., `{{chomp "

Blockhead

\n"}}` → `"

Blockhead

"` Converts the textual representation of the datetime into the other form or returns it of Go `time.Time` type value. These are formatted with the layout string. -e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` →"Wednesday, Jan 21, 2015" +e.g. `{{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}` → "Wednesday, Jan 21, 2015" ### highlight diff --git a/docs/content/tutorials/installing-on-windows.md b/docs/content/tutorials/installing-on-windows.md index d04e3c15f..7aee54039 100644 --- a/docs/content/tutorials/installing-on-windows.md +++ b/docs/content/tutorials/installing-on-windows.md @@ -54,31 +54,29 @@ Run a few commands to verify that the executable is ready to run and then build 2. At the prompt, type `hugo help` and press the Enter key. You should see output that starts with: -
A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io
-
+ {{< nohighlight >}}A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io +{{< /nohighlight >}} If you do, then the installation is complete. If you don't, double-check the path that you placed the `hugo.exe` file in and that you typed that path correctly when you added it to your PATH variable. If you're still not getting the output, post a note on the Hugo discussion list (in the `Support` topic) with your command and the output. 3. At the prompt, change your directory to the `Sites` directory. - ``` -C:\Program Files> cd D:\Hugo\Sites + {{< nohighlight >}}C:\Program Files> cd D:\Hugo\Sites C:\Program Files> D: D:\Hugo\Sites> -``` +{{< /nohighlight >}} 4. Run the command to generate a new site. I'm using `example.com` as the name of the site. - ``` -D:\Hugo\Sites> hugo new site example.com -``` + {{< nohighlight >}}D:\Hugo\Sites> hugo new site example.com +{{< /nohighlight >}} 5. You should now have a directory at `D:\Hugo\Sites\example.com`. Change into that directory and list the contents. You should get output similar to the following: -
D:\Hugo\Sites>cd example.com
+    {{< nohighlight >}}D:\Hugo\Sites>cd example.com
 D:\Hugo\Sites\example.com>dir
  Directory of D:\hugo\sites\example.com
-  
+ 
 04/13/2015  10:44 PM    <DIR>          .
 04/13/2015  10:44 PM    <DIR>          ..
 04/13/2015  10:44 PM    <DIR>          archetypes
@@ -89,7 +87,7 @@ D:\Hugo\Sites\example.com>dir
 04/13/2015  10:44 PM    <DIR>          static
                1 File(s)             83 bytes
                7 Dir(s)   6,273,331,200 bytes free
-
+{{< /nohighlight >}} You now have Hugo installed and a site to work with. You need to add a layout (or theme), then create some content. Go to http://gohugo.io/overview/quickstart/ for steps on doing that. diff --git a/docs/content/tutorials/migrate-from-jekyll.md b/docs/content/tutorials/migrate-from-jekyll.md index f736ee53a..e6592c0b4 100644 --- a/docs/content/tutorials/migrate-from-jekyll.md +++ b/docs/content/tutorials/migrate-from-jekyll.md @@ -62,59 +62,61 @@ As an example, I was using a custom [`image_tag`](https://github.com/alexandre-n Jekyll's plugin: - module Jekyll - class ImageTag < Liquid::Tag - @url = nil - @caption = nil - @class = nil - @link = nil - // Patterns - IMAGE_URL_WITH_CLASS_AND_CAPTION = - IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i - IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i - IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i - IMAGE_URL = /((https?:\/\/|\/)(\S+))/i - def initialize(tag_name, markup, tokens) - super - if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK - @class = $1 - @url = $3 - @caption = $7 - @link = $9 - elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION - @class = $1 - @url = $3 - @caption = $7 - elsif markup =~ IMAGE_URL_WITH_CAPTION - @url = $1 - @caption = $5 - elsif markup =~ IMAGE_URL_WITH_CLASS - @class = $1 - @url = $3 - elsif markup =~ IMAGE_URL - @url = $1 - end - end - def render(context) - if @class - source = "
" - else - source = "
" - end - if @link - source += "" - end - source += "" - if @link - source += "" - end - source += "
#{@caption}
" if @caption - source += "
" - source - end +```ruby +module Jekyll + class ImageTag < Liquid::Tag + @url = nil + @caption = nil + @class = nil + @link = nil + // Patterns + IMAGE_URL_WITH_CLASS_AND_CAPTION = + IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i + IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i + IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i + IMAGE_URL = /((https?:\/\/|\/)(\S+))/i + def initialize(tag_name, markup, tokens) + super + if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK + @class = $1 + @url = $3 + @caption = $7 + @link = $9 + elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION + @class = $1 + @url = $3 + @caption = $7 + elsif markup =~ IMAGE_URL_WITH_CAPTION + @url = $1 + @caption = $5 + elsif markup =~ IMAGE_URL_WITH_CLASS + @class = $1 + @url = $3 + elsif markup =~ IMAGE_URL + @url = $1 end end - Liquid::Template.register_tag('image', Jekyll::ImageTag) + def render(context) + if @class + source = "
" + else + source = "
" + end + if @link + source += "" + end + source += "" + if @link + source += "" + end + source += "
#{@caption}
" if @caption + source += "
" + source + end + end +end +Liquid::Template.register_tag('image', Jekyll::ImageTag) +``` is written as this Hugo shortcode: diff --git a/docs/layouts/shortcodes/nohighlight.html b/docs/layouts/shortcodes/nohighlight.html new file mode 100644 index 000000000..d9cb5f302 --- /dev/null +++ b/docs/layouts/shortcodes/nohighlight.html @@ -0,0 +1 @@ +
{{ .Inner }}