ref: cb8f459127615dd312f990ceeae4ac058cb9ec61
parent: 22bd485072b3d028a4338217d8bfadc5ace26759
author: Anthony Fok <[email protected]>
date: Wed Dec 23 04:31:07 EST 2015
Docs: Add nohighlight shortcode and improve formatting And some random formatting and copyediting fixes. See also #1708
--- a/docs/content/content/archetypes.md
+++ b/docs/content/content/archetypes.md
@@ -29,10 +29,12 @@
#### 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 <kbd>Enter</kbd> to type a carriage return after the closing `+++` or `---` as necessary.
@@ -47,12 +49,14 @@
#### 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 @@
#### archetypes/musician.md
- +++
- name = ""
- bio = ""
- genre = ""
- +++
+```toml
++++
+name = ""
+bio = ""
+genre = ""
++++
+```
Now let's create a new musician.
@@ -78,13 +84,15 @@
#### 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
--- a/docs/content/content/example.md
+++ b/docs/content/content/example.md
@@ -6,9 +6,9 @@
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 @@
With TOML front matter:
-```markdown
-+++
+<pre><code class="language-toml">+++
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,9 +28,8 @@
slug = "nitro"
project_url = "https://github.com/spf13/nitro"
+++
+</code><code class="language-markdown"># Nitro
-# Nitro
-
Quick and easy performance analyzer library for [Go](http://golang.org/).
## Overview
@@ -48,11 +46,11 @@
$ go get github.com/spf13/nitro
Next, include nitro in your application.
-```
+</code></pre>
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"
--- a/docs/content/content/front-matter.md
+++ b/docs/content/content/front-matter.md
@@ -28,50 +28,54 @@
## 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
+<pre><code class="language-toml">+++
+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"
++++
+</code><code class="language-markdown">Content of the file goes Here
+</code></pre>
## 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
--- a/docs/content/content/ordering.md
+++ b/docs/content/content/ordering.md
@@ -26,13 +26,14 @@
## 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
--- a/docs/content/content/sections.md
+++ b/docs/content/content/sections.md
@@ -17,17 +17,17 @@
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
--- a/docs/content/extras/aliases.md
+++ b/docs/content/extras/aliases.md
@@ -27,7 +27,7 @@
### TOML frontmatter
-~~~yaml
+```toml
+++
...
aliases = [
@@ -36,11 +36,11 @@
]
...
+++
-~~~
+```
### YAML frontmatter
-~~~yaml
+```yaml
---
...
aliases:
@@ -48,7 +48,7 @@
- /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.
@@ -55,8 +55,8 @@
## 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 @@
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
-~~~html
+```html
<!DOCTYPE html>
<html>
<head>
@@ -76,6 +76,6 @@
<meta http-equiv="refresh" content="0;url=http://mysite.tld/posts/my-original-url"/>
</head>
</html>
-~~~
+```
The `http-equiv="refresh"` line is what performs the redirect, in 0 seconds in this case.
--- a/docs/content/extras/crossreferences.md
+++ b/docs/content/extras/crossreferences.md
@@ -14,12 +14,14 @@
## Using `ref` and `relref`
- {{</* ref "document" */>}}
- {{</* ref "#anchor" */>}}
- {{</* ref "document#anchor" */>}}
- {{</* relref "document" */>}}
- {{</* relref "#anchor" */>}}
- {{</* relref "document#anchor" */>}}
+```django
+{{</* ref "document" */>}}
+{{</* ref "#anchor" */>}}
+{{</* ref "document#anchor" */>}}
+{{</* relref "document" */>}}
+{{</* relref "#anchor" */>}}
+{{</* relref "document#anchor" */>}}
+```
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`).
--- a/docs/content/overview/usage.md
+++ b/docs/content/overview/usage.md
@@ -14,7 +14,7 @@
Make sure either `hugo` is in your `PATH` or provide a path to it.
-<pre><code class="hljs nohighlight">$ 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 @@
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.
-</code></pre>
+{{< /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,16 +90,17 @@
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
@@ -105,18 +107,19 @@
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 @@
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 @@
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.
--- a/docs/content/taxonomies/methods.md
+++ b/docs/content/taxonomies/methods.md
@@ -16,39 +16,53 @@
A Taxonomy is a `map[string]WeightedPages`.
-**.Get(term)** Returns the WeightedPages for a term. <br>
-**.Count(term)** The number of pieces of content assigned to this term.<br>
-**.Alphabetical** Returns an OrderedTaxonomy (slice) ordered by Term. <br>
-**.ByCount** Returns an OrderedTaxonomy (slice) ordered by number of entries. <br>
+.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.<br>
-**.WeightedPages** A slice of Weighted Pages.<br>
-**.Count** The number of pieces of content assigned to this term.<br>
-**.Pages** All Pages assigned to this term. All [list methods](/templates/list/) are available to this.<br>
+.Term
+: The Term used.
-## WeightedPages
+.WeightedPages
+: A slice of Weighted Pages.
-WeightedPages is simply a slice of WeightedPage.
+.Count
+: The number of pieces of content assigned to this term.
- type WeightedPages []WeightedPage
+.Pages
+: All Pages assigned to this term. All [list methods](/templates/list/) are available to this.
-**.Count(term)** The number of pieces of content assigned to this term.<br>
-**.Pages** Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/). <br>
+## WeightedPages
+WeightedPages is simply a slice of WeightedPage.
+```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/).
--- a/docs/content/taxonomies/ordering.md
+++ b/docs/content/taxonomies/ordering.md
@@ -57,15 +57,16 @@
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`.
--- a/docs/content/taxonomies/usage.md
+++ b/docs/content/taxonomies/usage.md
@@ -30,10 +30,10 @@
</thead>
<tbody>
<tr valign="top">
-<td><pre><code>[taxonomies]
- tag = "tags"
- category = "categories"
- series = "series"
+<td><pre><code class="language-toml">[taxonomies]
+tag = "tags"
+category = "categories"
+series = "series"
</code></pre></td>
<td><pre><code class="language-yaml">taxonomies:
tag: "tags"
@@ -69,31 +69,35 @@
### 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"
+}
+```
--- a/docs/content/templates/functions.md
+++ b/docs/content/templates/functions.md
@@ -51,8 +51,8 @@
// 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 @@
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
--- a/docs/content/tutorials/installing-on-windows.md
+++ b/docs/content/tutorials/installing-on-windows.md
@@ -54,31 +54,29 @@
2. At the prompt, type `hugo help` and press the Enter key. You should see output that starts with:
- <pre><code class="hljs no-highlight">A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go. Complete documentation is available at http://gohugo.io
-</code></pre>
+ {{< 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:
- <pre><code class="hljs no-highlight">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 @@
04/13/2015 10:44 PM <DIR> static
1 File(s) 83 bytes
7 Dir(s) 6,273,331,200 bytes free
-</code></pre>
+{{< /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.
--- a/docs/content/tutorials/migrate-from-jekyll.md
+++ b/docs/content/tutorials/migrate-from-jekyll.md
@@ -62,59 +62,61 @@
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 = "<figure class='#{@class}'>"
- else
- source = "<figure>"
- end
- if @link
- source += "<a href=\"#{@link}\">"
- end
- source += "<img src=\"#{@url}\">"
- if @link
- source += "</a>"
- end
- source += "<figcaption>#{@caption}</figcaption>" if @caption
- source += "</figure>"
- 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 = "<figure class='#{@class}'>"
+ else
+ source = "<figure>"
+ end
+ if @link
+ source += "<a href=\"#{@link}\">"
+ end
+ source += "<img src=\"#{@url}\">"
+ if @link
+ source += "</a>"
+ end
+ source += "<figcaption>#{@caption}</figcaption>" if @caption
+ source += "</figure>"
+ source
+ end
+ end
+end
+Liquid::Template.register_tag('image', Jekyll::ImageTag)
+```
is written as this Hugo shortcode:
--- /dev/null
+++ b/docs/layouts/shortcodes/nohighlight.html
@@ -1,0 +1,1 @@
+<pre><code class="hljs nohighlight">{{ .Inner }}</code></pre>