summaryrefslogtreecommitdiffstats
path: root/markup
AgeCommit message (Collapse)Author
2022-03-11deps: Fix Goldmark regression with HTML commentsBjørn Erik Pedersen
Fixes #9650
2022-03-10Revert "markup/highlight: Add hl_inline option"Bjørn Erik Pedersen
This reverts commit a360cab75a073c2a8d47dcd27f52a6847e8d8d13.
2022-03-10Fail with error when double-rendering text in markdownify/RenderStringBjørn Erik Pedersen
This commit prevents the most commons case of infinite recursion in link render hooks when the `linkify` option is enabled (see below). This is always a user error, but getting a `stack overflow` (the current stack limit in Go is 1 GB on 64-bit, 250 MB on 32-bit) error isn't very helpful. This fix will not prevent all such errors, though, but we may do better once #9570 is in place. So, these will fail: ``` <a href="{{ .Destination | safeURL }}" >{{ .Text | markdownify }}</a> <a href="{{ .Destination | safeURL }}" >{{ .Text | .Page.RenderString }}</a> ``` `.Text` is already rendered to `HTML`. The above needs to be rewritten to: ``` <a href="{{ .Destination | safeURL }}" >{{ .Text | safeHTML }}</a> <a href="{{ .Destination | safeURL }}" >{{ .Text | safeHTML }}</a> ``` Fixes #8959
2022-03-09markup/goldmark: Default to https for linkifyBjørn Erik Pedersen
Fixes #9639
2022-03-09markup/highlight: Add hl_inline optionBjørn Erik Pedersen
If set to true, the highlighted code will not be wrapped in any div. Closes #9442
2022-03-08markup/goldmark/codeblocks: Fix slice bounds out of rangeBjørn Erik Pedersen
For the Position in code blocks we try to match the .Inner with the original source. This isn't always possible. This commits avoids panics in these situations. Fixes #9627
2022-03-02markup/goldmark: Escape image alt attributeJoe Mooring
Fixes #9594
2022-03-02tpl/transform: Fix it when template.HTML is passes as option to HightlightBjørn Erik Pedersen
Fixes #9591
2022-02-28markup/highlight: Ignore HL_lines_parsed in the gen docsBjørn Erik Pedersen
2022-02-27tpl/diagrams: Rename the SVG accessor to WrappedBjørn Erik Pedersen
Not perfect, but it gets it in line with the other .Inner/.Wrapped combos.
2022-02-27markup/highlight: Rework the return value from HighlightCodeblockBjørn Erik Pedersen
To make it possible to render it with a custom HTML ("<div>") wrapper. Updates #9573
2022-02-27CodeblockContext method renamesBjørn Erik Pedersen
Fixes #9577
2022-02-26markup/goldmark: Adjust test for WindowsBjørn Erik Pedersen
2022-02-26markup/goldmark: Improve attributes vs optionsBjørn Erik Pedersen
Fixes #9571
2022-02-26markup/goldmark: Add Position to CodeblockContextBjørn Erik Pedersen
But note that this is not particulary fast and the recommendad usage is error logging only. Updates #9574
2022-02-26 markup/goldmark: Unify some code block testsBjørn Erik Pedersen
2022-02-26Remove the trailing new line in .CodeBjørn Erik Pedersen
Fixes #9572
2022-02-26markup/goldmark: Rename extension structBjørn Erik Pedersen
2022-02-25markup/goldmark: Use Ordinal to create default lineanchorsBjørn Erik Pedersen
The `Ordinal` starts at 0, so with a `hl-` prefix, this gives `hl-0-1` as a starting point. Fixes #9567
2022-02-24Add test for line anchor attributes with code fencesKaushal Modi
Fixes https://github.com/gohugoio/hugo/issues/9385.
2022-02-24Add Markdown diagrams and render hooks for code blocksBjørn Erik Pedersen
You can now create custom hook templates for code blocks, either one for all (`render-codeblock.html`) or for a given code language (e.g. `render-codeblock-go.html`). We also used this new hook to add support for diagrams in Hugo: * Goat (Go ASCII Tool) is built-in and enabled by default; just create a fenced code block with the language `goat` and start draw your Ascii diagrams. * Another popular alternative for diagrams in Markdown, Mermaid (supported by GitHub), can also be implemented with a simple template. See the Hugo documentation for more information. Updates #7765 Closes #9538 Fixes #9553 Fixes #8520 Fixes #6702 Fixes #9558
2022-02-21markup/goldmark: Add BenchmarkCodeblocksBjørn Erik Pedersen
2022-02-16markup/goldmark: Exclude event attributes from markdown render hookJoe Mooring
Fixes #9511
2022-02-16markup/goldmark: Fix mangling of headers/links in render hooksBjørn Erik Pedersen
```bash name old time/op new time/op delta SiteWithRenderHooks-10 11.9ms ± 1% 11.9ms ± 1% ~ (p=0.486 n=4+4) name old alloc/op new alloc/op delta SiteWithRenderHooks-10 11.2MB ± 0% 11.3MB ± 0% +0.16% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteWithRenderHooks-10 145k ± 0% 145k ± 0% +0.14% (p=0.029 n=4+4) ``` Fixes #9504
2022-02-16markup/goldmark: Add a render hook benchmarkBjørn Erik Pedersen
Updates #9504
2022-02-15deps: Update github.com/alecthomas/chroma v0.9.4 => v0.10.0Bjørn Erik Pedersen
2022-02-10Exclude event attributes when rendering markdownJoe Mooring
Closes #9463
2022-01-16Do not render hl_style as an HTML attributeJoe Mooring
Fixes #9390
2022-01-04Remove mmarkBjørn Erik Pedersen
Closes #9350
2021-12-16Add some basic security policies with sensible defaultsBjørn Erik Pedersen
This ommmit contains some security hardening measures for the Hugo build runtime. There are some rarely used features in Hugo that would be good to have disabled by default. One example would be the "external helpers". For `asciidoctor` and some others we use Go's `os/exec` package to start a new process. These are a predefined set of binary names, all loaded from `PATH` and with a predefined set of arguments. Still, if you don't use `asciidoctor` in your project, you might as well have it turned off. You can configure your own in the new `security` configuration section, but the defaults are configured to create a minimal amount of site breakage. And if that do happen, you will get clear instructions in the loa about what to do. The default configuration is listed below. Note that almost all of these options are regular expression _whitelists_ (a string or a slice); the value `none` will block all. ```toml [security] enableInlineShortcodes = false [security.exec] allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$'] osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$'] [security.funcs] getenv = ['^HUGO_'] [security.http] methods = ['(?i)GET|POST'] urls = ['.*'] ```
2021-08-23highlight: Add tabindex when code is not highlightedHelder Pereira
2021-08-21highlight: Remove some pygments referencesHelder Pereira
2021-07-15markup: Add tabindex="0" to default <pre> wrapperrhymes
Currently the generated `<pre>` element isn't fully accessible as it can't be focused by keyboard users. To make this fully accessible, the attribute `tabindex="0"` should be added to the `<pre>` tag. Closes #7194
2021-07-15markup/goldmark: Rename/reorder the hook methodsBjørn Erik Pedersen
To make them easier to follow. See #8755
2021-07-15markup/goldmark: Support auto links in render hookBjørn Erik Pedersen
Fixes #8755
2021-06-19markup: Rename Header(s) to Heading(s) in ToC structBjørn Erik Pedersen
Because that is what it is.
2021-06-14Misc config loading fixesBjørn Erik Pedersen
The main motivation behind this is simplicity and correctnes, but the new small config library is also faster: ``` BenchmarkDefaultConfigProvider/Viper-16 252418 4546 ns/op 2720 B/op 30 allocs/op BenchmarkDefaultConfigProvider/Custom-16 450756 2651 ns/op 1008 B/op 6 allocs/op ``` Fixes #8633 Fixes #8618 Fixes #8630 Updates #8591 Closes #6680 Closes #5192
2021-04-12org: Disable broken pretty relative links featureNiklas Fasching
go-org PrettyRelativeLinks rewrites relative org links by - adding `../` in front - removing any `.org` suffix This was meant to play well with hugo pretty urls (which pretty much renders posts in a subdirectory without the file suffix) and allow use of normal org file links to reference other posts. There's a lot of edge cases I didn't consider and multiple bug reports in go-org [1] later I don't think the complexity of handling those edge cases is worth it - so let's disable it. [1] - https://github.com/niklasfasching/go-org/issues/53 - https://github.com/niklasfasching/go-org/commit/5dadf8c4c2924cbb3b93be45f96e1147596ca6f2 (comment) - https://github.com/niklasfasching/go-org/issues/51
2021-03-20Attributes for code fences should be placed after the lang indicator onlyBjørn Erik Pedersen
Fixes #8313
2021-03-09Fix output format handling for render hooksBjørn Erik Pedersen
Fixes #8176
2021-02-24markup: Handle attribute lists in code fencesBjørn Erik Pedersen
Fixes #8278
2021-02-23Allow markdown attribute lists to be used in title render hooksBjørn Erik Pedersen
Fixes #8270
2021-02-22Fixes #7698.gzagatti
markup: Allow installed arbitrary Asciidoc extension via path validation.
2021-02-09markup/goldmark: Fix handling of legacy attribute configBjørn Erik Pedersen
See #7548
2021-02-08markup/goldmark: Add attributes support for blocks (tables etc.)Bjørn Erik Pedersen
E.g.: ``` > foo > bar {.myclass} ``` There are some current limitations: For tables you can currently only apply it to the full table, and for lists the ul/ol-nodes only, e.g.: ``` * Fruit * Apple * Orange * Banana {.fruits} * Dairy * Milk * Cheese {.dairies} {.list} ``` Fixes #7548
2021-01-02deps: Update go-org to v1.4.0Niklas Fasching
- Add support for pretty urls [1]. Rewrite file links: 1. replace the `.org` extension with `/` (`/foo.org` -> `/foo/`) 2. prefix unrooted links with `../` as relative links start in the fake subdirectory `/foo/` rather than `/` - Fix case-sensitivity of org drawer `:end:` [1] https://gohugo.io/content-management/urls/#pretty-urls
2021-01-01rst: Adjust log levelBjørn Erik Pedersen
2020-12-30Add Dart Sass supportBjørn Erik Pedersen
But note that the Dart Sass Embedded Protocol is still in beta (beta 5), a main release scheduled for Q1 2021. Fixes #7380 Fixes #8102
2020-12-19Improve LookPathBjørn Erik Pedersen
2020-12-16all: Fix minor typosPhil Davis