From 61c27b58b353c73772aae572c7d822fdfdf7791b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 25 Sep 2017 09:02:42 +0200 Subject: [PATCH] Squashed 'docs/' changes from 1662b9d0..20959c7b 20959c7b Rewrite the syntax highlighter docs etc. 92435459 Add a note about branches REVERT: 1662b9d0 Add missing Disqus links in templates/internal.md git-subtree-dir: docs git-subtree-split: 20959c7b9124341dfc4d139748244818b9cb3641 --- README.md | 4 + config.toml | 5 + content/commands/_index.md | 22 -- content/commands/hugo.md | 5 +- content/commands/hugo_benchmark.md | 5 +- content/commands/hugo_check.md | 5 +- content/commands/hugo_check_ulimit.md | 5 +- content/commands/hugo_config.md | 5 +- content/commands/hugo_convert.md | 5 +- content/commands/hugo_convert_toJSON.md | 5 +- content/commands/hugo_convert_toTOML.md | 5 +- content/commands/hugo_convert_toYAML.md | 5 +- content/commands/hugo_env.md | 5 +- content/commands/hugo_gen.md | 6 +- content/commands/hugo_gen_autocomplete.md | 5 +- content/commands/hugo_gen_chromastyles.md | 46 ++++ content/commands/hugo_gen_doc.md | 5 +- content/commands/hugo_gen_man.md | 5 +- content/commands/hugo_import.md | 5 +- content/commands/hugo_import_jekyll.md | 5 +- content/commands/hugo_list.md | 5 +- content/commands/hugo_list_drafts.md | 5 +- content/commands/hugo_list_expired.md | 5 +- content/commands/hugo_list_future.md | 5 +- content/commands/hugo_new.md | 5 +- content/commands/hugo_new_site.md | 5 +- content/commands/hugo_new_theme.md | 5 +- content/commands/hugo_server.md | 7 +- content/commands/hugo_undraft.md | 5 +- content/commands/hugo_version.md | 5 +- .../content-management/syntax-highlighting.md | 188 ++++++++++++++ content/functions/highlight.md | 2 +- content/templates/internal.md | 2 - content/tools/syntax-highlighting.md | 237 ------------------ data/docs.json | 154 ++++++++++-- src/css/_chroma.css | 43 ++++ themes/gohugoioTheme/src/css/main.css | 2 +- .../gohugoioTheme/static/dist/app.bundle.js | 10 +- themes/gohugoioTheme/static/dist/main.css | 2 +- 39 files changed, 511 insertions(+), 339 deletions(-) delete mode 100644 content/commands/_index.md create mode 100644 content/commands/hugo_gen_chromastyles.md create mode 100644 content/content-management/syntax-highlighting.md delete mode 100644 content/tools/syntax-highlighting.md create mode 100644 src/css/_chroma.css diff --git a/README.md b/README.md index 3fbfcf1ca..d82776de3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ Note that this repository contains solely the documentation for Hugo. For contri *Pull requests shall **only** contain changes to the actual documentation. However, changes on the code base of Hugo **and** the documentation shall be a single, atomic pull request in the [hugo](https://github.com/gohugoio/hugo) repository.* +## Branches + +* The `master` branch is where the site is automatically built from, and is the place to put changes relevant to the current Hugo version. +* The `next` branch is where we store changes that is related to the next Hugo release. This can be previewed here: https://next--gohugoio.netlify.com/ ## Build diff --git a/config.toml b/config.toml index 9a09ef7c0..b7e13667d 100644 --- a/config.toml +++ b/config.toml @@ -21,6 +21,11 @@ disableAliases = true # It is (currently) not in use, but you can do ```go in a content file if you want to. pygmentsCodeFences = true +pygmentsOptions = "" +# Use the Chroma stylesheet +pygmentsUseClasses = true +pygmentsUseClassic = false + # See https://help.farbox.com/pygments.html pygmentsStyle = "friendly" diff --git a/content/commands/_index.md b/content/commands/_index.md deleted file mode 100644 index 0bd5667f8..000000000 --- a/content/commands/_index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: Command Line Reference -linktitle: CLI Overview -description: Comprehensive list of Hugo templating functions, including basic and advanced usage examples. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 -categories: [commands] -keywords: [cli,command line] -menu: - docs: - parent: "commands" - weight: 1 -weight: 01 #rem -draft: false -aliases: [/cli/] ---- - -The following list contains auto-generated and up-to-date (thanks to [Cobra][]) documentation for all the CLI commands in Hugo. - - -[Cobra]: https://github.com/spf13/cobra diff --git a/content/commands/hugo.md b/content/commands/hugo.md index 1246f78ca..1062291bf 100644 --- a/content/commands/hugo.md +++ b/content/commands/hugo.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo" slug: hugo url: /commands/hugo/ @@ -34,6 +34,7 @@ hugo [flags] --cleanDestinationDir remove files from destination not found in static directories --config string config file (default is path/config.yaml|json|toml) -c, --contentDir string filesystem path to content directory + --debug debug output -d, --destination string filesystem path to write files to --disable404 do not render 404 page --disableKinds stringSlice disable different kind of pages (home, RSS etc.) @@ -77,4 +78,4 @@ hugo [flags] * [hugo undraft](/commands/hugo_undraft/) - Undraft resets the content's draft status * [hugo version](/commands/hugo_version/) - Print the version number of Hugo -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_benchmark.md b/content/commands/hugo_benchmark.md index 2a7f9f8f4..c05cc71b5 100644 --- a/content/commands/hugo_benchmark.md +++ b/content/commands/hugo_benchmark.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo benchmark" slug: hugo_benchmark url: /commands/hugo_benchmark/ @@ -59,6 +59,7 @@ hugo benchmark [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -69,4 +70,4 @@ hugo benchmark [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_check.md b/content/commands/hugo_check.md index b7fb2c843..bfda906c1 100644 --- a/content/commands/hugo_check.md +++ b/content/commands/hugo_check.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo check" slug: hugo_check url: /commands/hugo_check/ @@ -23,6 +23,7 @@ Contains some verification checks ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -34,4 +35,4 @@ Contains some verification checks * [hugo](/commands/hugo/) - hugo builds your site * [hugo check ulimit](/commands/hugo_check_ulimit/) - Check system ulimit settings -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_check_ulimit.md b/content/commands/hugo_check_ulimit.md index c98c85111..ac14c24ae 100644 --- a/content/commands/hugo_check_ulimit.md +++ b/content/commands/hugo_check_ulimit.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo check ulimit" slug: hugo_check_ulimit url: /commands/hugo_check_ulimit/ @@ -28,6 +28,7 @@ hugo check ulimit [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -38,4 +39,4 @@ hugo check ulimit [flags] ### SEE ALSO * [hugo check](/commands/hugo_check/) - Contains some verification checks -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_config.md b/content/commands/hugo_config.md index 0dd2052f5..abe089bd8 100644 --- a/content/commands/hugo_config.md +++ b/content/commands/hugo_config.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo config" slug: hugo_config url: /commands/hugo_config/ @@ -27,6 +27,7 @@ hugo config [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -37,4 +38,4 @@ hugo config [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_convert.md b/content/commands/hugo_convert.md index 4202534ce..27a50bc3e 100644 --- a/content/commands/hugo_convert.md +++ b/content/commands/hugo_convert.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo convert" slug: hugo_convert url: /commands/hugo_convert/ @@ -28,6 +28,7 @@ See convert's subcommands toJSON, toTOML and toYAML for more information. ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -41,4 +42,4 @@ See convert's subcommands toJSON, toTOML and toYAML for more information. * [hugo convert toTOML](/commands/hugo_convert_totoml/) - Convert front matter to TOML * [hugo convert toYAML](/commands/hugo_convert_toyaml/) - Convert front matter to YAML -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_convert_toJSON.md b/content/commands/hugo_convert_toJSON.md index 36b1ffe2e..877be7477 100644 --- a/content/commands/hugo_convert_toJSON.md +++ b/content/commands/hugo_convert_toJSON.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo convert toJSON" slug: hugo_convert_toJSON url: /commands/hugo_convert_tojson/ @@ -28,6 +28,7 @@ hugo convert toJSON [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) -o, --output string filesystem path to write files to @@ -41,4 +42,4 @@ hugo convert toJSON [flags] ### SEE ALSO * [hugo convert](/commands/hugo_convert/) - Convert your content to different formats -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_convert_toTOML.md b/content/commands/hugo_convert_toTOML.md index 29c4f045e..e33e5d043 100644 --- a/content/commands/hugo_convert_toTOML.md +++ b/content/commands/hugo_convert_toTOML.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo convert toTOML" slug: hugo_convert_toTOML url: /commands/hugo_convert_totoml/ @@ -28,6 +28,7 @@ hugo convert toTOML [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) -o, --output string filesystem path to write files to @@ -41,4 +42,4 @@ hugo convert toTOML [flags] ### SEE ALSO * [hugo convert](/commands/hugo_convert/) - Convert your content to different formats -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_convert_toYAML.md b/content/commands/hugo_convert_toYAML.md index 37d305d32..a8667d2fa 100644 --- a/content/commands/hugo_convert_toYAML.md +++ b/content/commands/hugo_convert_toYAML.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo convert toYAML" slug: hugo_convert_toYAML url: /commands/hugo_convert_toyaml/ @@ -28,6 +28,7 @@ hugo convert toYAML [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) -o, --output string filesystem path to write files to @@ -41,4 +42,4 @@ hugo convert toYAML [flags] ### SEE ALSO * [hugo convert](/commands/hugo_convert/) - Convert your content to different formats -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_env.md b/content/commands/hugo_env.md index 1d3b45127..649bee682 100644 --- a/content/commands/hugo_env.md +++ b/content/commands/hugo_env.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo env" slug: hugo_env url: /commands/hugo_env/ @@ -27,6 +27,7 @@ hugo env [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -37,4 +38,4 @@ hugo env [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_gen.md b/content/commands/hugo_gen.md index 2aa9e228a..722275714 100644 --- a/content/commands/hugo_gen.md +++ b/content/commands/hugo_gen.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo gen" slug: hugo_gen url: /commands/hugo_gen/ @@ -23,6 +23,7 @@ A collection of several useful generators. ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -33,7 +34,8 @@ A collection of several useful generators. ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site * [hugo gen autocomplete](/commands/hugo_gen_autocomplete/) - Generate shell autocompletion script for Hugo +* [hugo gen chromastyles](/commands/hugo_gen_chromastyles/) - Generate CSS stylesheet for the Chroma code highlighter * [hugo gen doc](/commands/hugo_gen_doc/) - Generate Markdown documentation for the Hugo CLI. * [hugo gen man](/commands/hugo_gen_man/) - Generate man pages for the Hugo CLI -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_gen_autocomplete.md b/content/commands/hugo_gen_autocomplete.md index 95002dae8..6e0674bf7 100644 --- a/content/commands/hugo_gen_autocomplete.md +++ b/content/commands/hugo_gen_autocomplete.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo gen autocomplete" slug: hugo_gen_autocomplete url: /commands/hugo_gen_autocomplete/ @@ -45,6 +45,7 @@ hugo gen autocomplete [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -55,4 +56,4 @@ hugo gen autocomplete [flags] ### SEE ALSO * [hugo gen](/commands/hugo_gen/) - A collection of several useful generators. -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_gen_chromastyles.md b/content/commands/hugo_gen_chromastyles.md new file mode 100644 index 000000000..a070a213a --- /dev/null +++ b/content/commands/hugo_gen_chromastyles.md @@ -0,0 +1,46 @@ +--- +date: 2017-09-25T08:30:15+02:00 +title: "hugo gen chromastyles" +slug: hugo_gen_chromastyles +url: /commands/hugo_gen_chromastyles/ +--- +## hugo gen chromastyles + +Generate CSS stylesheet for the Chroma code highlighter + +### Synopsis + + +Generate CSS stylesheet for the Chroma code highlighter for a given style. This stylesheet is needed if pygmentsUseClasses is enabled in config. + +See https://help.farbox.com/pygments.html for preview of available styles + +``` +hugo gen chromastyles [flags] +``` + +### Options + +``` + -h, --help help for chromastyles + --highlightStyle string style used for highlighting lines (see https://github.com/alecthomas/chroma) (default "bg:#ffffcc") + --linesStyle string style used for line numbers (see https://github.com/alecthomas/chroma) + --style string highlighter style (see https://help.farbox.com/pygments.html) (default "friendly") +``` + +### Options inherited from parent commands + +``` + --config string config file (default is path/config.yaml|json|toml) + --debug debug output + --log enable Logging + --logFile string log File path (if set, logging enabled automatically) + --quiet build in quiet mode + -v, --verbose verbose output + --verboseLog verbose logging +``` + +### SEE ALSO +* [hugo gen](/commands/hugo_gen/) - A collection of several useful generators. + +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_gen_doc.md b/content/commands/hugo_gen_doc.md index e7dbd7ba3..b5daf3d9d 100644 --- a/content/commands/hugo_gen_doc.md +++ b/content/commands/hugo_gen_doc.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo gen doc" slug: hugo_gen_doc url: /commands/hugo_gen_doc/ @@ -34,6 +34,7 @@ hugo gen doc [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -44,4 +45,4 @@ hugo gen doc [flags] ### SEE ALSO * [hugo gen](/commands/hugo_gen/) - A collection of several useful generators. -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_gen_man.md b/content/commands/hugo_gen_man.md index 2e03d3714..52b062fc3 100644 --- a/content/commands/hugo_gen_man.md +++ b/content/commands/hugo_gen_man.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo gen man" slug: hugo_gen_man url: /commands/hugo_gen_man/ @@ -30,6 +30,7 @@ hugo gen man [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -40,4 +41,4 @@ hugo gen man [flags] ### SEE ALSO * [hugo gen](/commands/hugo_gen/) - A collection of several useful generators. -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_import.md b/content/commands/hugo_import.md index c46b1d0b9..3af546640 100644 --- a/content/commands/hugo_import.md +++ b/content/commands/hugo_import.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo import" slug: hugo_import url: /commands/hugo_import/ @@ -25,6 +25,7 @@ Import requires a subcommand, e.g. `hugo import jekyll jekyll_root_path target_p ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -36,4 +37,4 @@ Import requires a subcommand, e.g. `hugo import jekyll jekyll_root_path target_p * [hugo](/commands/hugo/) - hugo builds your site * [hugo import jekyll](/commands/hugo_import_jekyll/) - hugo import from Jekyll -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_import_jekyll.md b/content/commands/hugo_import_jekyll.md index 5edf76e29..156ac79ec 100644 --- a/content/commands/hugo_import_jekyll.md +++ b/content/commands/hugo_import_jekyll.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo import jekyll" slug: hugo_import_jekyll url: /commands/hugo_import_jekyll/ @@ -30,6 +30,7 @@ hugo import jekyll [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -40,4 +41,4 @@ hugo import jekyll [flags] ### SEE ALSO * [hugo import](/commands/hugo_import/) - Import your site from others. -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_list.md b/content/commands/hugo_list.md index 87d81bd15..cbd745ac5 100644 --- a/content/commands/hugo_list.md +++ b/content/commands/hugo_list.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo list" slug: hugo_list url: /commands/hugo_list/ @@ -26,6 +26,7 @@ List requires a subcommand, e.g. `hugo list drafts`. ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -39,4 +40,4 @@ List requires a subcommand, e.g. `hugo list drafts`. * [hugo list expired](/commands/hugo_list_expired/) - List all posts already expired * [hugo list future](/commands/hugo_list_future/) - List all posts dated in the future -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_list_drafts.md b/content/commands/hugo_list_drafts.md index 92d9fbc0d..d703a7d96 100644 --- a/content/commands/hugo_list_drafts.md +++ b/content/commands/hugo_list_drafts.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo list drafts" slug: hugo_list_drafts url: /commands/hugo_list_drafts/ @@ -27,6 +27,7 @@ hugo list drafts [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -38,4 +39,4 @@ hugo list drafts [flags] ### SEE ALSO * [hugo list](/commands/hugo_list/) - Listing out various types of content -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_list_expired.md b/content/commands/hugo_list_expired.md index 697ffe83d..dafffc4b1 100644 --- a/content/commands/hugo_list_expired.md +++ b/content/commands/hugo_list_expired.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo list expired" slug: hugo_list_expired url: /commands/hugo_list_expired/ @@ -28,6 +28,7 @@ hugo list expired [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -39,4 +40,4 @@ hugo list expired [flags] ### SEE ALSO * [hugo list](/commands/hugo_list/) - Listing out various types of content -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_list_future.md b/content/commands/hugo_list_future.md index 51b6089d1..95b5ba6de 100644 --- a/content/commands/hugo_list_future.md +++ b/content/commands/hugo_list_future.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo list future" slug: hugo_list_future url: /commands/hugo_list_future/ @@ -28,6 +28,7 @@ hugo list future [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -39,4 +40,4 @@ hugo list future [flags] ### SEE ALSO * [hugo list](/commands/hugo_list/) - Listing out various types of content -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_new.md b/content/commands/hugo_new.md index fa4eab688..281a1143c 100644 --- a/content/commands/hugo_new.md +++ b/content/commands/hugo_new.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo new" slug: hugo_new url: /commands/hugo_new/ @@ -35,6 +35,7 @@ hugo new [path] [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -47,4 +48,4 @@ hugo new [path] [flags] * [hugo new site](/commands/hugo_new_site/) - Create a new site (skeleton) * [hugo new theme](/commands/hugo_new_theme/) - Create a new theme -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_new_site.md b/content/commands/hugo_new_site.md index 3accfbbea..df9df1951 100644 --- a/content/commands/hugo_new_site.md +++ b/content/commands/hugo_new_site.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo new site" slug: hugo_new_site url: /commands/hugo_new_site/ @@ -31,6 +31,7 @@ hugo new site [path] [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -42,4 +43,4 @@ hugo new site [path] [flags] ### SEE ALSO * [hugo new](/commands/hugo_new/) - Create new content for your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_new_theme.md b/content/commands/hugo_new_theme.md index 928d11b56..f12935df3 100644 --- a/content/commands/hugo_new_theme.md +++ b/content/commands/hugo_new_theme.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo new theme" slug: hugo_new_theme url: /commands/hugo_new_theme/ @@ -30,6 +30,7 @@ hugo new theme [name] [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -41,4 +42,4 @@ hugo new theme [name] [flags] ### SEE ALSO * [hugo new](/commands/hugo_new/) - Create new content for your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_server.md b/content/commands/hugo_server.md index 5b58a52f0..082b223b2 100644 --- a/content/commands/hugo_server.md +++ b/content/commands/hugo_server.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo server" slug: hugo_server url: /commands/hugo_server/ @@ -53,10 +53,12 @@ hugo server [flags] --i18n-warnings print missing translations --ignoreCache ignores the cache directory -l, --layoutDir string filesystem path to layout directory + --liveReloadPort int port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1) --meminterval string interval to poll memory usage (requires --memstats), valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". (default "100ms") --memstats string log memory usage to this file --navigateToChanged navigate to changed content file on live browser reload --noChmod don't sync permission mode of files + --noHTTPCache prevent HTTP caching (default true) --noTimes don't sync modification time of files --pluralizeListTitles pluralize titles in lists using inflect (default true) -p, --port int port on which the server will listen (default 1313) @@ -74,6 +76,7 @@ hugo server [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -84,4 +87,4 @@ hugo server [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_undraft.md b/content/commands/hugo_undraft.md index bb408b80b..601463cd0 100644 --- a/content/commands/hugo_undraft.md +++ b/content/commands/hugo_undraft.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo undraft" slug: hugo_undraft url: /commands/hugo_undraft/ @@ -29,6 +29,7 @@ hugo undraft path/to/content [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -39,4 +40,4 @@ hugo undraft path/to/content [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/commands/hugo_version.md b/content/commands/hugo_version.md index 522ff1008..fc999196a 100644 --- a/content/commands/hugo_version.md +++ b/content/commands/hugo_version.md @@ -1,5 +1,5 @@ --- -date: 2017-07-16T23:23:14+02:00 +date: 2017-09-25T08:30:15+02:00 title: "hugo version" slug: hugo_version url: /commands/hugo_version/ @@ -27,6 +27,7 @@ hugo version [flags] ``` --config string config file (default is path/config.yaml|json|toml) + --debug debug output --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode @@ -37,4 +38,4 @@ hugo version [flags] ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site -###### Auto generated by spf13/cobra on 16-Jul-2017 +###### Auto generated by spf13/cobra on 25-Sep-2017 diff --git a/content/content-management/syntax-highlighting.md b/content/content-management/syntax-highlighting.md new file mode 100644 index 000000000..9b801ed20 --- /dev/null +++ b/content/content-management/syntax-highlighting.md @@ -0,0 +1,188 @@ +--- +title: Syntax Highlighting +description: Hugo comes with reallly fast syntax highlighting from Chroma. +date: 2017-02-01 +publishdate: 2017-02-01 +keywords: [highlighting,pygments,chroma,code blocks,syntax] +categories: [content management] +menu: + docs: + parent: "content-management" + weight: 300 +weight: 20 +sections_weight: 20 +draft: false +aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/] +toc: true +--- + +From Hugo 0.28, the default syntax hightlighter in Hugo is [Chroma](https://github.com/alecthomas/chroma); it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments. + +If you want to continue to use Pygments (see below), set `pygmentsUseClassic=true` in your site config. + +The example below shows a simple code snippet from the Hugo source highlighted with the `highlight` shortcode. Note that the gohugo.io site is generated with `pygmentsUseClasses=true` (see [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css)). + +* `linenos=inline` turns on line numbers. Note that the `inline` value only has an effect in Pygments. +* `hl_lines` lists a set of line numbers or line number ranges to be highlighted. Note that the hyphen range syntax is only supported for Chroma. +* `linenostart=199` starts the line number count from 199. + +With that, this: + +``` +{{}} +// ... code +{{}} +``` + +Gives this: + +{{< highlight go "linenos=inline,hl_lines=8 15-17,linenostart=199" >}} +// GetTitleFunc returns a func that can be used to transform a string to +// title case. +// +// The supported styles are +// +// - "Go" (strings.Title) +// - "AP" (see https://www.apstylebook.com/) +// - "Chicago" (see http://www.chicagomanualofstyle.org/home.html) +// +// If an unknown or empty style is provided, AP style is what you get. +func GetTitleFunc(style string) func(s string) string { + switch strings.ToLower(style) { + case "go": + return strings.Title + case "chicago": + tc := transform.NewTitleConverter(transform.ChicagoStyle) + return tc.Title + default: + tc := transform.NewTitleConverter(transform.APStyle) + return tc.Title + } +} +{{< / highlight >}} + + +## Configure Syntax Hightlighter +To make the transition from Pygments to Chroma seamless, they share a common set of configuration options: + +pygmentsOptions +: A comma separated list of options. See below for a full list. + +pygmentsCodefences +: Set to true to enable syntax highlighting in code fences with a language tag in markdown (see below for an example). + +pygmentsStyle +: The style of code highlighting. See https://help.farbox.com/pygments.html for a gallery. Note that this option is not relevant when `pygmentsUseClasses` is set. + +pygmentsUseClasses +: Set to `true` to use CSS classes to format your highlighted code. See [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css). + +pygmentsCodefencesGuessSyntax +: Set to `true` to try to do syntax highlighting on code fenced blocks in markdown without a language tag. + +pygmentsUseClassic +: Set to true to use Pygments instead of the much faster Chroma. + +### Options + +`pygmentsOptions` can be set either in site config or overridden per code block in the Highlight shortcode or template func. + +noclasses +: Use inline style. + +linenos +: For Chroma, any value in this setting will print line numbers. Pygments has some more fine grained control. + +linenostart +: Start the line numbers from this value (default is 1). + + +hl_lines +: Highlight a space separated list of line numbers. For Chroma, you can provide a list of ranges, i.e. "3-8 10-20". + + +The full set of supported options for Pygments is: `encoding`, `outencoding`, `nowrap`, `full`, `title`, `style`, `noclasses`, `classprefix`, `cssclass`, `cssstyles`, `prestyles`, `linenos`, `hl_lines`, `linenostart`, `linenostep`, `linenospecial`, `nobackground`, `lineseparator`, `lineanchors`, `linespans`, `anchorlinenos`, `startinline`. See the [Pygments Documentation](http://pygments.org/) for details. + + +## Generate Syntax Highlighter CSS + +If you run with `pygmentsUseClassic=true` in your site config, you need a style sheet. + +You can generate one with Hugo: + +```bash +hugo gen chromastyles --style=monokai > syntax.css +``` + +Run `hugo gen chromastyles -h` for more options. See https://help.farbox.com/pygments.html for a gallery of available styles. + + +## Highlight Shortcode + +Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. + +### Example `highlight` Shortcode + +{{< code file="example-highlight-shortcode-input.md" >}} +{{}} +
+
+

{{ .Title }}

+ {{ range .Data.Pages }} + {{ .Render "summary"}} + {{ end }} +
+
+{{}} +{{< /code >}} + + + +## Highlight Template Func + +See [Highlight](/functions/highlight/). + +## Highlight in Code Fences + +It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `pygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/); + +```` +```html +
+
+

{{ .Title }}

+ {{ range .Data.Pages }} + {{ .Render "summary"}} + {{ end }} +
+
+``` +```` + + +## Highlight with Pygments Classic + +If you for some reason don't want to use the built-in Chroma highlighter, you can set `pygmentsUseClassic=true` in your config and add Pygments to your path. + +{{% note "Disclaimers on Pygments" %}} +* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk. +* The caching can be turned off by setting the `--ignoreCache` flag to `true`. +* The languages available for highlighting depend on your Pygments installation. +{{% /note %}} + +If you have never worked with Pygments before, here is a brief primer: + ++ Install Python from [python.org](https://www.python.org/downloads/). Version 2.7.x is already sufficient. ++ Run `pip install Pygments` in order to install Pygments. Once installed, Pygments gives you a command `pygmentize`. Make sure it sits in your PATH; otherwise, Hugo will not be able to find and use it. + +On Debian and Ubuntu systems, you may also install Pygments by running `sudo apt-get install python3-pygments`. + + + +[Prism]: http://prismjs.com +[prismdownload]: http://prismjs.com/download.html +[Highlight.js]: http://highlightjs.org/ +[Rainbow]: http://craig.is/making/rainbows +[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/ +[Google Prettify]: https://github.com/google/code-prettify +[Yandex]: http://yandex.ru/ diff --git a/content/functions/highlight.md b/content/functions/highlight.md index 8796de4e8..0ea73cf0f 100644 --- a/content/functions/highlight.md +++ b/content/functions/highlight.md @@ -11,7 +11,7 @@ menu: docs: parent: "functions" keywords: [highlighting,pygments,code blocks,syntax] -signature: ["highlight INPUT"] +signature: ["highlight INPUT LANG OPTIONS"] workson: [] hugoversion: relatedfuncs: [] diff --git a/content/templates/internal.md b/content/templates/internal.md index 6f8d4e864..20390c2f5 100644 --- a/content/templates/internal.md +++ b/content/templates/internal.md @@ -129,5 +129,3 @@ You can then render your custom Disqus partial template as follows: * `_internal/schema.html` * `_internal/twitter_cards.html` -[disqus]: https://disqus.com -[disqussignup]: https://disqus.com/profile/signup/ diff --git a/content/tools/syntax-highlighting.md b/content/tools/syntax-highlighting.md deleted file mode 100644 index e45236cee..000000000 --- a/content/tools/syntax-highlighting.md +++ /dev/null @@ -1,237 +0,0 @@ ---- -title: Syntax Highlighting -linktitle: -description: Hugo provides server-side syntax highlighting via Pygments and, like most static site generators, works very well with client-side (JavaScript) syntax highlighting libraries as well. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 -keywords: [highlighting,pygments,code blocks,syntax] -categories: [developer tools] -menu: - docs: - parent: "tools" - weight: 20 -weight: 20 -sections_weight: 20 -draft: false -aliases: [/extras/highlighting/,/extras/highlight/] -toc: true ---- - -Hugo can highlight source code in _two different ways_—either pre-processed server side from your content or to defer the processing to the client side, using a JavaScript library. - -## Server-side - -For the pre-processed approach, highlighting is performed by an external Python-based program called [Pygments](http://pygments.org/) and is triggered via an embedded Hugo shortcode (see [example](#example-highlight-shortcode-input) below). If Pygments is absent from the path, it will silently simply pass the content along without highlighting. - -### Server-side Advantages - -The advantages of server-side syntax highlighting are that it doesn’t depend on a JavaScript library and, consequently, works very well when read from an RSS feed. - -### Pygments - -If you have never worked with Pygments before, here is a brief primer: - -+ Install Python from [python.org](https://www.python.org/downloads/). Version 2.7.x is already sufficient. -+ Run `pip install Pygments` in order to install Pygments. Once installed, Pygments gives you a command `pygmentize`. Make sure it sits in your PATH; otherwise, Hugo will not be able to find and use it. - -On Debian and Ubuntu systems, you may also install Pygments by running `sudo apt-get install python3-pygments`. - -Hugo gives you two options that you can set with the variable `pygmentsuseclasses` (default `false`) in your [site configuration](/getting-started/configuration/). - -1. Color codes for highlighting keywords are directly inserted if `pygmentsuseclasses = false` (default). The color codes depend on your choice of the `pygmentsstyle` (default = `"monokai"`). You can explore the different color styles on [pygments.org](http://pygments.org/) after inserting some example code. -2. If you choose `pygmentsuseclasses = true`, Hugo includes class names in your code instead of color codes. For class-names to be meaningful, you need to include a `.css` file in your website representing your color scheme. You can either generate this `.css` files according to the [description from the Pygments documentation](http://pygments.org/docs/cmdline/) or download the one of the many pre-built color schemes from [Pygment's GitHub css repository](https://github.com/richleland/pygments-css). - -### Server-side Usage - -Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. - -### Example `highlight` Shortcode Input - -{{< code file="example-highlight-shortcode-input.md" >}} -{{}} -
-
-

{{ .Title }}

- {{ range .Data.Pages }} - {{ .Render "summary"}} - {{ end }} -
-
-{{}} -{{< /code >}} - -### Example `highlight` Shortcode Output - -{{< output file="example-highlight-shortcode-output.html" >}} -<section id="main"> - <div> - <h1 id="title">{{ .Title }}</h1> - {{ range .Data.Pages }} - {{ .Render "summary"}} - {{ end }} - </div> -</section> -{{< /output >}} - -### Options - -Options for controlling highlighting can be added in the second argument as a quoted, comma-separated key-value list. The example below will syntax highlight in `go` with inline line numbers and line numbers 2 and 3 highlighted. - -``` -{{}} -var a string -var b string -var c string -var d string -{{}} -``` - -The `highlight` shortcode includes the following supported keywords: - -* `style` -* `encoding` -* `noclasses` -* `hl_lines` -* `linenos` - -Note that `style` and `noclasses` will override the similar setting in the [global config](/getting-started/configuration/). - -The keywords in the `highlight` shortcode mirror those of Pygments from the command line. See the [Pygments documentation](http://pygments.org/docs/) for more information. - -### Code Fences - -It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `PygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/); - -```` -``` -
-
-

{{ .Title }}

- {{ range .Data.Pages }} - {{ .Render "summary"}} - {{ end }} -
-
-``` -```` - -{{% note "Disclaimers on Pygments" %}} -* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk. -* The caching can be turned off by setting the `--ignoreCache` flag to `true`. -* The languages available for highlighting depend on your Pygments installation. -{{% /note %}} - -## Client-side - -Alternatively, code highlighting can be applied to your code blocks in client-side JavaScript. - -Client-side syntax highlighting is very simple to add. You'll need to pick -a library and a corresponding theme. Some popular libraries are: - -- [Highlight.js] -- [Prism] -- [Rainbow] -- [Syntax Highlighter] -- [Google Prettify] - -### Client-side Advantages - -The advantages of client-side syntax highlighting are that it doesn’t cost anything when building your site, and some of the highlighting scripts available cover more languages than Pygments does. - -### Highlight.js Example - -This example uses the popular [Highlight.js] library, hosted by [Yandex], a popular Russian search engine. - -In your `./layouts/partials/` (or `./layouts/chrome/`) folder, depending on your specific theme, there will be a snippet that will be included in every generated HTML page, such as `header.html` or `header.includes.html`. Simply add the css and js to initialize [Highlight.js]: - -``` - - - -``` - -### Prism example - -Prism is another popular highlighter library and is used on some major sites. -The [download section of the prism.js website][prismdownload] is simple to use and affords you a high degree of customization to pick only the languages you'll be using on your site. - -Similar to Highlight.js, you simply load `prism.css` in your `` via whatever Hugo partial template is creating that part of your pages: - -``` -... - -... -``` - -Add `prism.js` near the bottom of your `` tag in whatever Hugo partial template is appropriate for your site or theme. - -``` -... - - -``` - -In this example, the local paths indicate that your downloaded copy of these files are being added to the site, typically under `./static/css/` and `./static/js/`, respectively. - -### Client-side Usage - -To use client-side highlighting, most of these javascript libraries expect your code to be wrapped in semantically correct `` elements with language-specific class attributes. For example, a code block for HTML would have `class="language-html"`. - -The client-side highlighting script therefore looks for programming language classes according to this convention: `language-go`, `language-html`, `language-css`, `language-bash`, etc. If you look at the page's source, you might see something like the following: - -``` -
-  
-  body {
-    font-family: "Noto Sans", sans-serif;
-  }
-  
-
-``` - -If you are using markdown, your content pages needs to use the following syntax, with the name of the language to be highlighted entered directly after the first "fence." A fenced code block can be noted by opening and closing triple tilde ~ or triple back ticks `: - -{{< nohighlight >}} -~~~css -body { - font-family: "Noto Sans", sans-serif; -} -~~~ -{{< /nohighlight >}} - -Here is the same example but with triple back ticks to denote the fenced code block: - -{{< nohighlight >}} -```css -body { - font-family: "Noto Sans", sans-serif; -} -``` -{{< /nohighlight >}} - -Passing the above examples through the highlighter script would yield the following markup: - -{{< nohighlight >}} -<pre><code class="language-css hljs">;<span class="hljs-selector-tag">body</span> { - <span class="hljs-attribute">font-family</span>: <span class="hljs-string">"Noto Sans"</span>, sans-serif; -} -{{< /nohighlight >}} - -In the case of the coding color scheme used by the Hugo docs, the resulting output would then look like the following to the website's end users: - -``` -body { - font-family: "Noto Sans", sans-serif; -} -``` - -Please see individual libraries' documentation for how to implement each of the JavaScript-based libraries. - -[Prism]: http://prismjs.com -[prismdownload]: http://prismjs.com/download.html -[Highlight.js]: http://highlightjs.org/ -[Rainbow]: http://craig.is/making/rainbows -[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/ -[Google Prettify]: https://github.com/google/code-prettify -[Yandex]: http://yandex.ru/ diff --git a/data/docs.json b/data/docs.json index 59ab28281..0708a2358 100644 --- a/data/docs.json +++ b/data/docs.json @@ -384,6 +384,23 @@ } }, "compare": { + "Conditional": { + "Description": "Conditional can be used as a ternary operator.\nIt returns a if condition, else b.", + "Args": [ + "condition", + "a", + "b" + ], + "Aliases": [ + "cond" + ], + "Examples": [ + [ + "{{ cond (eq (add 2 2) 4) \"2+2 is 4\" \"what?\" | safeHTML }}", + "2+2 is 4" + ] + ] + }, "Default": { "Description": "Default checks whether a given value is set and returns a default value if it\nis not. \"Set\" in this context means non-zero for numeric types and times;\nnon-zero length for strings, arrays, slices, and maps;\nany boolean or struct value; or non-nil for any other types.", "Args": [ @@ -604,6 +621,22 @@ ], "Examples": [] }, + "KeyVals": { + "Description": "KeyVals creates a key and values wrapper.", + "Args": [ + "key", + "vals" + ], + "Aliases": [ + "keyVals" + ], + "Examples": [ + [ + "{{ keyVals \"key\" \"a\" \"b\" }}", + "key: [a b]" + ] + ] + }, "Last": { "Description": "Last returns the last N items in a rangeable list.", "Args": [ @@ -856,7 +889,7 @@ }, "fmt": { "Print": { - "Description": "", + "Description": "Print returns string representation of the passed arguments.", "Args": [ "a" ], @@ -871,7 +904,7 @@ ] }, "Printf": { - "Description": "", + "Description": "Printf returns a formatted string representation of the passed arguments.", "Args": [ "format", "a" @@ -887,7 +920,7 @@ ] }, "Println": { - "Description": "", + "Description": "Print returns string representation of the passed arguments ending with a newline.", "Args": [ "a" ], @@ -1020,7 +1053,7 @@ }, "math": { "Add": { - "Description": "", + "Description": "Add adds two numbers.", "Args": [ "a", "b" @@ -1036,7 +1069,7 @@ ] }, "Div": { - "Description": "", + "Description": "Div divides two numbers.", "Args": [ "a", "b" @@ -1052,7 +1085,7 @@ ] }, "Log": { - "Description": "", + "Description": "Log returns the natural logarithm of a number.", "Args": [ "a" ], @@ -1097,7 +1130,7 @@ ] }, "Mul": { - "Description": "", + "Description": "Mul multiplies two numbers.", "Args": [ "a", "b" @@ -1113,7 +1146,7 @@ ] }, "Sub": { - "Description": "", + "Description": "Sub subtracts two numbers.", "Args": [ "a", "b" @@ -1156,7 +1189,7 @@ ] }, "ReadFile": { - "Description": "ReadFilereads the file named by filename relative to the configured\nWorkingDir. It returns the contents as a string. There is a upper size\nlimit set at 1 megabytes.", + "Description": "ReadFile reads the file named by filename relative to the configured WorkingDir.\nIt returns the contents as a string.\nThere is an upper size limit set at 1 megabytes.", "Args": [ "i" ], @@ -1469,6 +1502,10 @@ [ "{{title \"Bat man\"}}", "Bat Man" + ], + [ + "{{title \"somewhere over the rainbow\"}}", + "Somewhere Over the Rainbow" ] ] }, @@ -1518,20 +1555,72 @@ ] ] }, - "TrimPrefix": { - "Description": "", - "Args": null, + "TrimLeft": { + "Description": "TrimLeft returns a slice of the string s with all leading characters\ncontained in cutset removed.", + "Args": [ + "cutset", + "s" + ], "Aliases": null, - "Examples": null + "Examples": [ + [ + "{{ \"aabbaa\" | strings.TrimLeft \"a\" }}", + "bbaa" + ] + ] + }, + "TrimPrefix": { + "Description": "TrimPrefix returns s without the provided leading prefix string. If s doesn't\nstart with prefix, s is returned unchanged.", + "Args": [ + "prefix", + "s" + ], + "Aliases": null, + "Examples": [ + [ + "{{ \"aabbaa\" | strings.TrimPrefix \"a\" }}", + "abbaa" + ], + [ + "{{ \"aabbaa\" | strings.TrimPrefix \"aa\" }}", + "bbaa" + ] + ] + }, + "TrimRight": { + "Description": "TrimRight returns a slice of the string s with all trailing characters\ncontained in cutset removed.", + "Args": [ + "cutset", + "s" + ], + "Aliases": null, + "Examples": [ + [ + "{{ \"aabbaa\" | strings.TrimRight \"a\" }}", + "aabb" + ] + ] }, "TrimSuffix": { - "Description": "", - "Args": null, + "Description": "TrimSuffix returns s without the provided trailing suffix string. If s\ndoesn't end with suffix, s is returned unchanged.", + "Args": [ + "suffix", + "s" + ], "Aliases": null, - "Examples": null + "Examples": [ + [ + "{{ \"aabbaa\" | strings.TrimSuffix \"a\" }}", + "aabba" + ], + [ + "{{ \"aabbaa\" | strings.TrimSuffix \"aa\" }}", + "aabb" + ] + ] }, "Truncate": { - "Description": "", + "Description": "Truncate truncates a given string to the specified length.", "Args": [ "a", "options" @@ -1565,6 +1654,22 @@ ] ] }, + "Duration": { + "Description": "Duration converts the given number to a time.Duration.\nUnit is one of nanosecond/ns, microsecond/us/µs, millisecond/ms, second/s, minute/m or hour/h.", + "Args": [ + "unit", + "number" + ], + "Aliases": [ + "duration" + ], + "Examples": [ + [ + "{{ mul 60 60 | duration \"second\" }}", + "1h0m0s" + ] + ] + }, "Format": { "Description": "Format converts the textual representation of the datetime string into\nthe other form or returns it of the time.Time value. These are formatted\nwith the layout string", "Args": [ @@ -1588,6 +1693,19 @@ "now" ], "Examples": [] + }, + "ParseDuration": { + "Description": "ParseDuration parses a duration string.\nA duration string is a possibly signed sequence of\ndecimal numbers, each with optional fraction and a unit suffix,\nsuch as \"300ms\", \"-1.5h\" or \"2h45m\".\nValid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".\nSee https://golang.org/pkg/time/#ParseDuration", + "Args": [ + "in" + ], + "Aliases": null, + "Examples": [ + [ + "{{ \"1h12m10s\" | time.ParseDuration }}", + "1h12m10s" + ] + ] } }, "transform": { @@ -1763,7 +1881,7 @@ "Examples": [] }, "URLize": { - "Description": "", + "Description": "URLize returns the given argument formatted as URL.", "Args": [ "a" ], diff --git a/src/css/_chroma.css b/src/css/_chroma.css new file mode 100644 index 000000000..1ad06604b --- /dev/null +++ b/src/css/_chroma.css @@ -0,0 +1,43 @@ +/* Background */ .chroma { background-color: #f0f0f0 } +/* Error */ .chroma .ss4 { } +/* LineHighlight */ .chroma .hl { background-color: #ffffcc; display: block; width: 100% } +/* LineNumbers */ .chroma .ln { ; margin-right: 0.4em; padding: 0 0.4em 0 0.4em; } +/* Keyword */ .chroma .s3e8 { color: #007020; font-weight: bold } +/* KeywordPseudo */ .chroma .s3ec { color: #007020 } +/* KeywordType */ .chroma .s3ee { color: #902000 } +/* NameAttribute */ .chroma .s7d1 { color: #4070a0 } +/* NameBuiltin */ .chroma .s7d2 { color: #007020 } +/* NameClass */ .chroma .s7d4 { color: #0e84b5; font-weight: bold } +/* NameConstant */ .chroma .s7d5 { color: #60add5 } +/* NameDecorator */ .chroma .s7d6 { color: #555555; font-weight: bold } +/* NameEntity */ .chroma .s7d7 { color: #d55537; font-weight: bold } +/* NameException */ .chroma .s7d8 { color: #007020 } +/* NameFunction */ .chroma .s7d9 { color: #06287e } +/* NameLabel */ .chroma .s7dc { color: #002070; font-weight: bold } +/* NameNamespace */ .chroma .s7dd { color: #0e84b5; font-weight: bold } +/* NameTag */ .chroma .s7e2 { color: #062873; font-weight: bold } +/* NameVariable */ .chroma .s7e3 { color: #bb60d5 } +/* LiteralString */ .chroma .sc1c { color: #4070a0 } +/* LiteralStringDoc */ .chroma .sc23 { color: #4070a0; font-style: italic } +/* LiteralStringEscape */ .chroma .sc25 { color: #4070a0; font-weight: bold } +/* LiteralStringInterpol */ .chroma .sc27 { color: #70a0d0; font-style: italic } +/* LiteralStringOther */ .chroma .sc29 { color: #c65d09 } +/* LiteralStringRegex */ .chroma .sc2a { color: #235388 } +/* LiteralStringSymbol */ .chroma .sc2c { color: #517918 } +/* LiteralNumber */ .chroma .sc80 { color: #40a070 } +/* Operator */ .chroma .sfa0 { color: #666666 } +/* OperatorWord */ .chroma .sfa1 { color: #007020; font-weight: bold } +/* Comment */ .chroma .s1770 { color: #60a0b0; font-style: italic } +/* CommentSpecial */ .chroma .s1774 { color: #60a0b0; background-color: #fff0f0 } +/* CommentPreproc */ .chroma .s17d4 { color: #007020 } +/* GenericDeleted */ .chroma .s1b59 { color: #a00000 } +/* GenericEmph */ .chroma .s1b5a { font-style: italic } +/* GenericError */ .chroma .s1b5b { color: #ff0000 } +/* GenericHeading */ .chroma .s1b5c { color: #000080; font-weight: bold } +/* GenericInserted */ .chroma .s1b5d { color: #00a000 } +/* GenericOutput */ .chroma .s1b5e { color: #888888 } +/* GenericPrompt */ .chroma .s1b5f { color: #c65d09; font-weight: bold } +/* GenericStrong */ .chroma .s1b60 { font-weight: bold } +/* GenericSubheading */ .chroma .s1b61 { color: #800080; font-weight: bold } +/* GenericTraceback */ .chroma .s1b62 { color: #0044dd } +/* TextWhitespace */ .chroma .s1f41 { color: #bbbbbb } diff --git a/themes/gohugoioTheme/src/css/main.css b/themes/gohugoioTheme/src/css/main.css index cdaa5e2c0..912bf5ce5 100755 --- a/themes/gohugoioTheme/src/css/main.css +++ b/themes/gohugoioTheme/src/css/main.css @@ -25,7 +25,7 @@ @import '_stickyheader'; @import '_svg'; - +@import '_chroma'; @import '_variables'; .nested-blockquote blockquote { diff --git a/themes/gohugoioTheme/static/dist/app.bundle.js b/themes/gohugoioTheme/static/dist/app.bundle.js index a83366d5d..6cf4e374e 100644 --- a/themes/gohugoioTheme/static/dist/app.bundle.js +++ b/themes/gohugoioTheme/static/dist/app.bundle.js @@ -4,19 +4,19 @@ * * Licensed MIT © Zeno Rocha */ -!function(e){t.exports=e()}(function(){var t;return function t(e,n,i){function o(a,u){if(!n[a]){if(!e[a]){var c="function"==typeof r&&r;if(!u&&c)return r(a,!0);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var h=n[a]={exports:{}};e[a][0].call(h.exports,function(t){var n=e[a][1][t];return o(n||t)},h,h.exports,t,e,n,i)}return n[a].exports}for(var s="function"==typeof r&&r,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,r.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,r.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":i(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=s})},{select:5}],8:[function(e,n,r){!function(i,o){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],o);else if(void 0!==r)o(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var s={exports:{}};o(s,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=s.exports}}(this,function(t,e,n,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var c=i(e),l=i(n),h=i(r),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===f(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,h.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new c.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return u("action",t)}},{key:"defaultTarget",value:function(t){var e=u("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return u("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),e}(l.default);t.exports=d})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)})},function(t,e,n){/*! docsearch 2.3.3 | © Algolia | github.com/algolia/docsearch */ -!function(e,n){t.exports=n()}(0,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=46)}([function(t,e,n){"use strict";function r(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var i=n(1);t.exports={isArray:null,isFunction:null,isObject:null,bind:null,each:null,map:null,mixin:null,isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isNumber:function(t){return"number"==typeof t},toStr:function(t){return void 0===t||null===t?"":t+""},cloneDeep:function(t){var e=this.mixin({},t),n=this;return this.each(e,function(t,r){t&&(n.isArray(t)?e[r]=[].concat(t):n.isObject(t)&&(e[r]=n.cloneDeep(t)))}),e},error:function(t){throw new Error(t)},every:function(t,e){var n=!0;return t?(this.each(t,function(r,i){if(!(n=e.call(null,r,i,t)))return!1}),!!n):n},any:function(t,e){var n=!1;return t?(this.each(t,function(r,i){if(e.call(null,r,i,t))return n=!0,!1}),n):n},getUniqueId:function(){var t=0;return function(){return t++}}(),templatify:function(t){if(this.isFunction(t))return t;var e=i.element(t);return"SCRIPT"===e.prop("tagName")?function(){return e.text()}:function(){return String(t)}},defer:function(t){setTimeout(t,0)},noop:function(){},formatPrefix:function(t,e){return e?"":t+"-"},className:function(t,e,n){return(n?"":".")+t+e},escapeHighlightedString:function(t,e,n){e=e||"";var i=document.createElement("div");i.appendChild(document.createTextNode(e)),n=n||"";var o=document.createElement("div");o.appendChild(document.createTextNode(n));var s=document.createElement("div");return s.appendChild(document.createTextNode(t)),s.innerHTML.replace(RegExp(r(i.innerHTML),"g"),e).replace(RegExp(r(o.innerHTML),"g"),n)}}},function(t,e,n){"use strict";t.exports={element:null}},function(t,e){var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString;t.exports=function(t,e,i){if("[object Function]"!==r.call(e))throw new TypeError("iterator must be a function");var o=t.length;if(o===+o)for(var s=0;s was loaded but did not call our provided callback"),JSONPScriptError:i("JSONPScriptError","