summaryrefslogtreecommitdiffstats
path: root/helpers/content_test.go
AgeCommit message (Collapse)Author
2018-05-29Add a BlackFriday option for rel="noreferrer" on external linksStefan Neuhaus
Add a configuration option "noreferrerLinks". When set to "true" the "HTML_NOREFERRER_LINKS" flag is being passed to Blackfriday. Thereby all *absolute* links will get a "noreferrer" value for their "rel" attribute. See #4722
2018-05-28Add a BlackFriday option for rel="nofollow" on external linksStefan Neuhaus
Add a configuration option "nofollowLinks". When set to "true" the "HTML_NOFOLLOW_LINKS" flag is being passed to Blackfriday. Thereby all *absolute* links will get a "nofollow" value for the "rel" attribute. Fixes #4722
2017-12-27:sparkles: Implement Page bundling and image handlingBjørn Erik Pedersen
This commit is not the smallest in Hugo's history. Some hightlights include: * Page bundles (for complete articles, keeping images and content together etc.). * Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`. * Processed images are cached inside `resources/_gen/images` (default) in your project. * Symbolic links (both files and dirs) are now allowed anywhere inside /content * A new table based build summary * The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below). A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory: ```bash ▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render" benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64% ``` Fixes #3651 Closes #3158 Fixes #1014 Closes #2021 Fixes #1240 Updates #3757
2017-12-16Reuse the BlackFriday instance when possibleBjørn Erik Pedersen
This is in heavy use in rendering, so this makes a difference: ```bash benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 124551144 107743429 -13.49% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 528684 435118 -17.70% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 53306848 45147832 -15.31% ```
2017-09-29Change SummaryLength to be configurable (#3924)Brendan Roy
Move SummaryLength into the ContentSpec struct and refactor the relevant summary functions to be methods of ContentSpec. The new summaryLength struct member is configurable by the summaryLength config value, and the default remains 70. Also updates hugolib/page to use the refactored methods. Resolves #3734
2017-08-02Remove sourceRelativeLinksBjørn Erik Pedersen
Fixes #3766
2017-07-29helpers: Add support for French GuillemetsBjørn Erik Pedersen
Fixes #3725
2017-04-22helpers: Delete RenderingContext.getConfigAlbert Nigmatzianov
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-01-05helpers: Remove unusded WordCountBjørn Erik Pedersen
2016-09-14Lazy calculate WordCount, ReadingTime and FuzzyWordCountBjørn Erik Pedersen
This avoids having to execute these expensive operations for sites not using these values. This commit sums up a set of wordcounting and autosummary related performance improvements. The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 21293005843 20032857342 -5.92% benchmark old allocs new allocs delta BenchmarkHugo-4 65290922 65186032 -0.16% benchmark old bytes new bytes delta BenchmarkHugo-4 9771213416 9681866464 -0.91% ``` Closes #2378
2016-09-14Improve TotalWords counter funcBjørn Erik Pedersen
It is obviously more efficient when we do not care about the actual words. ``` BenchmarkTotalWords-4 100000 18795 ns/op 0 B/op 0 allocs/op BenchmarkTotalWordsOld-4 30000 46751 ns/op 6400 B/op 1 allocs/op ```
2016-09-14Avoid splitting words for summaryBjørn Erik Pedersen
For people using autogenerated summaries, this is one of the hot spots in the memory department. We don't need to split al the content into words to do proper summary truncation. This is obviously more effective: ``` BenchmarkTestTruncateWordsToWholeSentence-4 300000 4720 ns/op 0 B/op 0 allocs/op BenchmarkTestTruncateWordsToWholeSentenceOld-4 100000 17699 ns/op 3072 B/op 3 allocs/op ```
2016-09-06Multilingual TODO-fixes, take 1Bjørn Erik Pedersen
See #2309
2016-09-06Make it possible to configure Blackfroday per languageBjørn Erik Pedersen
See #2309
2016-07-10Consolidate the Render funcsBjørn Erik Pedersen
2016-04-12Revert "Use Node.ID for anchor ID"Bjørn Erik Pedersen
This reverts commit cd558958a0c0ecd06f7560a38e27334fe983e0de.
2016-04-11Use Node.ID for anchor IDBjørn Erik Pedersen
Fixes #2057
2016-03-21helpers: Rename getMmarkHtmlRenderer to getMmarkHTMLRendererAnthony Fok
To be consistent with the changes made in commit 67df33f, see #959.
2016-03-20helpers: Support EXTENSION_BACKSLASH_LINE_BREAK for BlackfridayAnthony Fok
Exposed as "backslashLineBreak" and enabled by default as upstream have done. Fixes #1935
2016-03-20helpers: Fix minor typo in content_test.goAnthony Fok
2016-03-14helpers: Unexport some internalsBjørn Erik Pedersen
2016-02-06helpers: Test coverage increaseGergely Brautigam
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
2015-12-10Add copyright header to that source files that don’t have one.Anthony Fok
See #1646
2015-10-07WordCount and Summary support CJK Languagecoderzh
* 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-09-12WordCount Summary support UTF-8 stringcoderzh
2015-03-11Correct initialisms as suggested by golintAnthony Fok
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-02-06Add benchmark test for StripHTMLbep
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-05Fix Truncatebep
TruncateWordsToWholeSentence knows if the summary is truncated, so let "him" decide. Fixes #880
2015-02-05Replace 4 strings.Replace with 1 strings.Replacerbep
Consumes less memory, slightly faster.
2015-01-27Add more tests to helperbep
2015-01-09Moved a test regarding a content.go function to a new test file content_test.go.Marek Stanley
Added some tests for general helpers, especially as a way to document the expected behavior, and as a warm-up welcome contribution.