Commit graph

16 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
39c9ae3108 Revert "Use Node.ID for anchor ID"
This reverts commit cd558958a0.
2016-04-12 18:11:24 +02:00
Bjørn Erik Pedersen
cd558958a0 Use Node.ID for anchor ID
Fixes #2057
2016-04-11 13:17:25 +02: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
5d915e7e96 helpers: Unexport some internals 2016-03-14 17:27:15 +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
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
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
coderzh
0e1fd78fb2 WordCount Summary support UTF-8 string 2015-09-12 15:41:17 +02:00
Anthony Fok
67df33f500 Correct initialisms as suggested by golint
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing #959.
2015-03-11 21:55:00 +01:00
bep
43e48a8989 Add benchmark test for StripHTML
go test -test.run=NONE -bench=".*" -test.benchmem=true ./helpers

Old vs new impl (string.Replace vs string.Replacer):

benchmark              old ns/op     new ns/op     delta
BenchmarkStripHTML     10210         6572          -35.63%

benchmark              old allocs     new allocs     delta
BenchmarkStripHTML     6              5              -16.67%

benchmark              old bytes     new bytes     delta
BenchmarkStripHTML     1456          848           -41.76%
2015-02-06 10:00:42 +01:00
bep
48b6777ea2 Fix Truncate
TruncateWordsToWholeSentence knows if the summary is truncated, so let "him" decide.

Fixes #880
2015-02-05 14:04:48 -07:00
bep
2bee4a1570 Replace 4 strings.Replace with 1 strings.Replacer
Consumes less memory, slightly faster.
2015-02-05 18:31:11 +01:00
bep
5f9596e68c Add more tests to helper 2015-01-27 10:15:57 +01:00
Marek Stanley
49f5eb5c84 Moved a test regarding a content.go function to a new test file content_test.go.
Added some tests for general helpers, especially as a way to document the expected behavior,
and as a warm-up welcome contribution.
2015-01-09 12:42:13 +01:00