Commit graph

253 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 4f00f1c94f heloers: Add a linefeed to make Golint happy 2016-03-23 00:07:44 +01:00
Bjørn Erik Pedersen b0e21f967b helpers: Silence some Golint warnings 2016-03-22 23:53:19 +01:00
Bjørn Erik Pedersen b9127ecca6 helpers: Apply gofmt 2016-03-22 19:43:03 +01:00
Bjørn Erik Pedersen e5aa477491 Add support for symbolic links for content, layout, static, theme
Note: This is for the content roots only, but that should satisfy most needs.

Fixes #1855
2016-03-21 19:13:29 -04:00
Aditya Bhargava c42982f76b Add '+' as one of the valid characters in urls specified in the front matter
Fixes #1290
2016-03-21 18:48:50 -04:00
Anthony Fok d45b55bdd4 helpers: Rename getMmarkHtmlRenderer to getMmarkHTMLRenderer
To be consistent with the changes made in commit 67df33f, see #959.
2016-03-21 15:17:37 +08:00
Anthony Fok 2c5e4f7640 helpers: Support EXTENSION_BACKSLASH_LINE_BREAK for Blackfriday
Exposed as "backslashLineBreak" and enabled by default
as upstream have done.

Fixes #1935
2016-03-20 04:21:16 +08:00
Anthony Fok 4c4ce55217 helpers: Fix minor typo in content_test.go 2016-03-20 04:12:53 +08:00
Bjørn Erik Pedersen 0a768ec95f Simplify GetDottedRelativePath 2016-03-19 17:17:17 +01:00
Bjørn Erik Pedersen 8d86f1ec6e Return early from parseOptions 2016-03-19 17:12:10 +01:00
Bjørn Erik Pedersen 70739c972e Remove unnecessary type conversions 2016-03-14 20:35:50 +01:00
Bjørn Erik Pedersen 5d915e7e96 helpers: Unexport some internals 2016-03-14 17:27:15 +01:00
Bjørn Erik Pedersen 91ffc76b24 helpers: Remove unused code 2016-03-14 15:20:36 +01:00
Bjørn Erik Pedersen 542e220cc4 Make tests green on both Pygments 2.0.2 and 2.1.3
See #1969
2016-03-13 22:06:51 +01:00
Bjørn Erik Pedersen cafb784799 Add emoji support
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation.

The built-in are fine for most use cases, but in Hugo we do care about pure speed.

The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice,
Kyokomi's implementation works best with strings.

Curious: The easy-to-use `strings.Replacer` is also plenty fast.

```
BenchmarkEmojiKyokomiFprint-4  	   20000	     86038 ns/op	   33960 B/op	     117 allocs/op
BenchmarkEmojiKyokomiSprint-4  	   20000	     83252 ns/op	   38232 B/op	     122 allocs/op
BenchmarkEmojiStringsReplacer-4	  100000	     21092 ns/op	   17248 B/op	      25 allocs/op
BenchmarkHugoEmoji-4           	  500000	      5728 ns/op	     624 B/op	      13 allocs/op
```

Fixes #1891
2016-03-11 15:51:37 -06:00
Marek Janda 0962470850 Make absURL properly handle baseURL with path component 2016-03-10 11:08:50 +01:00
Bjørn Erik Pedersen a2abad9677 Add support for Go 1.6 block keyword in templates
NOTE: Needs Go 1.6 to use the new feature.

Fixes #1832
2016-03-10 10:53:54 +01:00
Bjørn Erik Pedersen 5b065a27a2 Some missing shortcode replacements
See #1904
2016-03-01 13:51:46 +01:00
Bjørn Erik Pedersen 7f682d7802 Fix shortcode handling in RST
Fixes #1904
2016-03-01 11:04:25 +01:00
Gergely Brautigam e95f3af933 helpers: Test coverage increase
Started to increase coverage in helpers package, now at 74.9% of statements.

In the process, also a few minor changes have been applied to content.go.

* Content.go has undergone a formatting refactor regarding comments
* Unused function TruncateWords has been removed
* RenderingContext's "mmark" has been changed to use MmarkRender
* Content_test.go added to cover content.go's functionality
2016-02-06 14:27:11 +01:00
Bjørn Erik Pedersen 318a984526 Apply gofmt -s 2016-02-06 13:09:52 +01:00
Bjørn Erik Pedersen 5def6d9aee Make the watch logger less chatty 2016-01-28 15:33:41 +01:00
Bjørn Erik Pedersen 3054a46185 Make the DistinctErrorLogger more generic 2016-01-28 15:33:41 +01:00
Ben Thomas 26d23f7f4b added remaining relevant options 2016-01-04 11:52:40 -05:00
Ben Thomas e904ccffb6 added more pygments opts 2016-01-04 11:52:40 -05:00
John McFarlane b1f2b433bc Fix /.xml RSSLink when uglyurls are enabled
Prior to this commit the root url with uglyurls enabled is "/.xml".
This commit relates to #175.
2016-01-04 11:25:37 -05:00
Sven Dowideit 0f6b334b67 Source file based relative linking
ala GitHub repository markdown for both md files and non-md files

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-01-01 15:23:11 -05:00
digitalcraftsman 47587321d9 Add themesDir option to configuration
themesDir can be used to change the default
path of the themes folder.

Fixes 1556
2016-01-01 14:46:40 -05:00
Daniel TISCHER 40fccf2251 Fixes #1292 2016-01-01 14:35:58 -05:00
Anthony Fok de82404d35 Fix hugo server "Watching for changes" path display
especially when the given `--source` path is a relative directory.

Also, when `--source` is specified, make WorkingDir an absolute path
from the very beginning, to be consistent with the case when `--source`
is not given.  Otherwise, the function name helpers.AbsPathify(), which
prepends WorkingDir to a relative path, does not really make sense.

Fixes #1721
2015-12-19 05:19:31 -07:00
Anthony Fok 8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Steve Francia 6042fc2b83 move some of the path helper utilities to afero
and provide wrappers in Hugo.
2015-12-08 16:46:43 -05:00
Bjørn Erik Pedersen e445c35d6a Fix copyright headers in source files
Still need to add some missing headers and an AUTHORS file.

See #1646
2015-12-07 19:57:01 +01:00
Steve Francia d356720f74 Version bump to 0.16-DEV 2015-11-25 09:49:03 -05:00
Steve Francia 6faf1d01e0 version bump to v0.15 2015-11-25 09:33:53 -05:00
Steve Francia f045d7a611 Change the license to Apache 2.0 2015-11-23 22:16:36 -05:00
Bjørn Erik Pedersen b00771ca14 Simplify ExtractRootPaths 2015-11-23 22:35:54 +01:00
Andrew Brampton c3931ef748 Add PygmentsOptions option
This allows default pygments settings to be used, if none are explictly set per shortcode.

Fixes #1260
2015-11-23 17:50:54 +01:00
Marek Janda 5838420aa1 Move blackfriday site-wide config loading to NewBlackFriday() 2015-11-23 17:35:36 +01:00
Bjørn Erik Pedersen 831e936846 Improve "watching for ..." logging 2015-11-23 16:32:06 +01:00
Anthony Fok 8727475596 Fix missing word in code comment (my own fault) 2015-11-22 09:40:22 -07:00
Bjørn Erik Pedersen 8d8fa7222f Remove some superficial tests 2015-11-19 20:27:02 +01:00
Anthony Fok e95db67b20 Add smartDashes flag for Blackfriday
To allow the end users to disable any form of smart dashes
(LaTeX-style or not) while keeping the rest of Blackfriday
SmartyPants features.

Depends on https://github.com/russross/blackfriday/pull/190
"Add HTML_SMARTYPANTS_DASHES for toggling smart dashes"
to be accepted by Blackfriday developers.
2015-10-30 13:30:25 -06:00
Bjørn Erik Pedersen 36adb5fb88 Preserve Unicode marks in MakePath
Fixes #1488
2015-10-18 10:36:27 +02:00
Nathan Youngman ec9c691216 Insert code tag for server-side syntax highlighting
Inserts a code tag into Pygments output with the language-info that is present when using client-side highlighting (useful for CSS hooks)

```html
<code class="language-go" data-lang="go">
```

closes #1490
2015-10-15 17:59:28 +02:00
Bjørn Erik Pedersen 6a3aced15a Rename prettiyPath to prettifyPath 2015-10-15 10:15:26 +02:00
Bjørn Erik Pedersen 5619fe52d3 Unexport internal path helper 2015-10-14 21:34:34 +02:00
Bjørn Erik Pedersen 72f14a8202 Apply project wide go fmt 2015-10-12 20:47:06 +02:00
Alexander Morozov 7b4e4769d0 Fix comment for NormalizeHugoFlags 2015-10-07 21:28:29 +02:00
coderzh 823334875d WordCount and Summary support CJK Language
* add global `hasCJKLanguage` flag, if true, turn on auto-detecting CJKLanguage
 * add `isCJKLanguage` frontmatter to force specify whether is CJKLanguage or not
 * For .Summary: If isCJKLanguage is true, use the runes as basis for truncation, else keep as today.
 * For WordCount: If isCJKLanguage is true, use the runes as basis for calculation, else keep as today.
 * Unexport RuneCount

Fixes #1377
2015-10-07 15:14:57 +02:00
Andrew Brampton c2c694f136 Add GitHub style code fence support to mmark
Fixes #1258.
2015-10-05 17:45:37 -04:00
Bjørn Erik Pedersen 218554e363 Rename NormalizeHugoFlagsFunc to NormalizeHugoFlags
It IS a func.
2015-10-02 06:48:02 +02:00
Bjørn Erik Pedersen f5308da320 Move isThemeVsHugoVersionMismatch to /commands
To prevent potential package cycles in /helpers.
2015-09-14 17:31:39 +02:00
Anthony Fok d05b297e61 Add helpers.NormalizeHugoFlagsFunc() to handle flag name changes
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue #959
2015-09-13 05:20:14 -06:00
coderzh 0e1fd78fb2 WordCount Summary support UTF-8 string 2015-09-12 15:41:17 +02:00
chrongzhang 52d94fa675 Add config option "disablePathToLower"
Enabling this prevents lowercasing of the path/url.

Fixes #557
2015-09-01 15:26:02 +02:00
Bjørn Erik Pedersen 5b90b388cb Unexport FileAndExt
If needed outside helpers, create an exported file path (FilePathAndExt?)  and/or a url version.
2015-08-26 21:29:32 +02:00
Bjørn Erik Pedersen b05a292c21 Revert "Fix some Go code doc issues"
This reverts commit de7dd70bbc.

Broke the code fence feat.
2015-08-07 20:09:40 +02:00
Bjørn Erik Pedersen de7dd70bbc Fix some Go code doc issues 2015-08-06 22:58:10 +02:00
Anthony Fok 4a2eda49cd Add option to disable Blackfriday Smartypants
Can be used in site config or per page front matter:

```
[blackfriday]
smartypants = false
```
2015-08-04 21:42:32 +02:00
Baptiste Mathus b23b546a30 Asciidoc[tor]: use --no-header-footer option
This simplifies the retrieval of the HTML (no more need to extract the
part within body) and also removes the unwanted "Last Updated" part in
the article.
2015-07-29 17:36:19 +02:00
Bjørn Erik Pedersen 77c60a3440 Add RuneCount to Page
Fixes #1266
2015-07-12 11:05:37 +02:00
Andrew Brampton c139c6e1ef Add support for GitHub-flavoured markdown code fences for highlighting
This commit adds a new PygmentsCodeFences config option (default false), which if true will allow GitHub style backtick code fences around code, which will then be rendered by Pygments.

For example:

``` language
your code
```

can be used instead of {{< highlight language >}}your code {{< /highlight >}}.

Fixes #362
2015-07-08 08:12:52 +02:00
Andrew Brampton fdab118010 If no language is provided to Pygments, then try and guess it
Previously if no language was specified, then illegal args would be passed to pygments, for example `pygments -l -fhtml`, which would result in pygments printing an error.
2015-07-08 08:12:06 +02:00
Bjørn Erik Pedersen 483fc8fa3d Add config option for Blackfriday HTML_HREF_TARGET_BLANK
Fixes #1220
2015-06-28 15:18:15 +02:00
Bjørn Erik Pedersen 05c07c561a Add option to disable Blackfriday LaTeX style dashes
Can be used in site config of per page front matter:

```
[blackfriday]
latexDashes = false
```

Fixes #1231
2015-06-28 15:08:52 +02:00
Jonathan Anderson 1058cb17d1 Refactor theme path helper functions.
Reduce duplication (`x + FilePathSeparator + y` a few lines away from `filepath.Join(x, y)`) and add a `GetThemeDir()` function to get the current theme's directory.

Also add a comment complaining about the `GetThemesDirPath()` function, which doesn't seem to do what its name would suggest. This might be a candidate for deprecation?
2015-06-25 18:05:43 +02:00
Bjørn Erik Pedersen 50269f2512 Remove superfluous return 2015-06-16 22:31:51 +02:00
Bjørn Erik Pedersen 4b7c1342fd Make removal of accents in taxonomy and section paths optional
And default off.

Fixes #1180
2015-06-16 19:25:48 +02:00
Vincent Batoufflet 82cc1ac0f8 Add Blackfriday definition lists extension support 2015-06-15 21:15:05 +02:00
bep beeae6ab69 Add some tests for IgnoreFiles
And log error on invalid regexp.

See #1189
2015-06-03 18:54:15 +02:00
bep 3ea4df35f2 Remove accents in URLs
So the taxonomy `Gérard Depardieu` gives paths on the form `gerard-depardieu`.

Unfortunately this introduces two imports from the `golang.org/`, but Unicode-normalization isn't something we'd want to write from scratch.

See https://blog.golang.org/normalization

See #1180
2015-05-31 20:30:45 +02:00
bep be7404e337 Support Fish and Chips section
Section names are also used as the title of the list pages, but naming section folders as `Fish and Chips` and similar didn't work very well.

This commit fixes that.

This commit also changes the title casing of the section titles. Some may argue that this is a breaking change, but the old behaviour was also pretty broken,
even for languages that use title capitalizations, as it didn't follow any particular style guide, `fish and chips` became `Fish And Chips` etc.

Now it just turns the first letter into upper case, so `Fish and Chips` will be left as `Fish and Chips`.

People wanting the good old behaviour can use the `title` template func.

Fixes #1176
2015-05-28 23:05:17 +02:00
bep be964e95a1 Never remove trailing slash in RelPermalink
Fixed #1174
2015-05-27 20:41:43 +02:00
bep beaa008c2f Make deprecated warning for this release more alert 2015-05-26 23:08:25 +02:00
bep be381683ff Hyphenate DEV version 2015-05-26 22:44:39 +02:00
spf13 d4de261508 bumping master version to v0.15-DEV 2015-05-25 21:46:29 -04:00
spf13 6af9d6789e Bump version to Hugo v0.14.0 2015-05-25 11:59:47 -04:00
bep beee679dfb Unexport filepath/path bridge types
They are of no use outside the helpers package.

See #1160
2015-05-25 13:10:40 +02:00
bep be79c35bda Pass RenderingContext by reference in Mmark 2015-05-25 12:57:58 +02:00
spf13 a584ff207b Stop Viper from leaking across many of the tests (now tests pass regardless of order tested) 2015-05-20 02:21:21 -04:00
bep beaa8b1bca Add support for URLs relative to context root
Setting `RelativeURLs` to `true` will make all relative URLs in the site *really* relative.

And will do so with speed.

So:

In `/post/myblogpost.html`:

`/mycss.css` becomes `../mycss.css`

The same in `/index.html` will become:

`./mycss.css` etc.

Note that absolute URLs will not be touched (either external resources, or URLs constructed with `BaseURL`).

The speediness is about the same as before:

```
benchmark                    old ns/op     new ns/op     delta
BenchmarkAbsURL              17462         18164         +4.02%
BenchmarkAbsURLSrcset        18842         19632         +4.19%
BenchmarkXMLAbsURLSrcset     18643         19313         +3.59%
BenchmarkXMLAbsURL           9283          9656          +4.02%

benchmark                    old allocs     new allocs     delta
BenchmarkAbsURL              24             28             +16.67%
BenchmarkAbsURLSrcset        29             32             +10.34%
BenchmarkXMLAbsURLSrcset     27             30             +11.11%
BenchmarkXMLAbsURL           12             14             +16.67%

benchmark                    old bytes     new bytes     delta
BenchmarkAbsURL              3154          3404          +7.93%
BenchmarkAbsURLSrcset        2376          2573          +8.29%
BenchmarkXMLAbsURLSrcset     2569          2763          +7.55%
BenchmarkXMLAbsURL           1888          1998          +5.83%

```

Fixes #1104
Fixes #622
Fixes #937
Fixes #157
2015-05-16 00:11:44 +02:00
bep bec839e652 Add relURL template func
Fixes #1126
2015-05-11 13:59:02 +02:00
bep be0cbeee7f Add absURL template func
Fixes #1106
2015-05-11 12:28:35 +02:00
bep bec90e0850 Make page 1 alias ugly
When `uglyurls = true`

Fixes #1121
2015-05-10 18:28:44 +02:00
bep a52e508d46 Update test logs for uniformity and consistency
Many minor fixes to make test logs more consistent and correct a
mispelling.

Standardize on "[%i] got X but expected Y" for log messages. Using
a consistent layout makes it easier to read the test results. This
was mostly changing "Got" to "got". Swapped the order of values on
several calls to bring them in line with the convention.

A few log messages had a sequence number added to identify the
exact scenario that failed. Otherwise, there would be no way to
ascertain which failed When there are many scenarios.

Correct spelling of "expected."

Fixes #1028
Merged be2097e1ad

[close #1040]
2015-05-08 22:27:00 -04:00
Anthony Fok 563a6302a0 Very experimental support for mmark
Either name the content files as `*.mmark`,
or add `markup = "mmark"` in the front matter
of your `*.md` content files.
2015-05-08 22:05:41 -04:00
Yosuke INOUE 3596b1b810 Add blackfriday/ExtensionsMask option. 2015-05-07 21:12:28 +02:00
Andrew Gallant ee5a1bbf44 Allow 'classprefix' pygments options. 2015-05-07 03:45:51 +02:00
bep bea9280fb3 Do not add trailing slash to baseURL
Fixes #1105
2015-05-05 16:02:44 +02:00
bep be7b830f33 tpl: add sanity check to prevent panic in seq on big nums
Fixes #1092
2015-04-30 13:25:46 +02:00
bep be29c0bfbd Print ERROR on theme vs Hugo version mismatch
Fixes #1070
2015-04-28 20:39:25 +02:00
bep be0d977009 Only write highlight to cache when CacheDir is set
To avoid writing cache files when testing.
2015-04-16 02:27:23 +02:00
bep be24457acf Add more options to highlight
Fixes #1021
2015-04-15 20:31:06 +02:00
bep be540f5b8f Fix potential Windows path issue with Pygments cache 2015-04-14 19:58:33 +02:00
bep beb66c19a4 helpers: add some missing documentation 2015-04-03 22:30:08 +02:00
bep bea42218b6 helpers: fix some go vet errors 2015-04-03 21:20:25 +02:00
bep bea5feb34d Return early from DistinctErrorLogger's Printf 2015-04-03 21:16:32 +02:00
Dylan MacKenzie 99a18b21fc List directories being watched when server is run
Fixes part of issue 1030. Previously hugo only listed the content
directory as being watched. Now we list all files being watched
according to `commands.getDirList()`. We also introduce a RemoveSubpaths
function and test in the helpers module to reduce noise in the command
line output by not showing subdirectories of ones already being watched.

For example, instead of:
`Watching for changes in $HOME/blog/content`
We get:
`Watching for changes in
$HOME/blog/{data,content,layouts,static,themes/my-theme}`
2015-04-02 12:52:08 +02:00
bep bec4bdae99 Return error on wrong use of the Paginator
`Paginate`now returns error when

1) `.Paginate` is called after `.Paginator`
2) `.Paginate` is repeatedly called with different arguments

This should help remove some confusion.

This commit also introduces DistinctErrorLogger, to prevent spamming the log for duplicate rendering errors from the pagers.

Fixes #993
2015-03-31 22:33:17 +02:00