Commit graph

11 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 10928a4f78 Remove the trailing new line in .Code
Fixes #9572
2022-02-26 21:54:36 +01:00
Bjørn Erik Pedersen 0f80be341f markup/goldmark: Use Ordinal to create default lineanchors
The `Ordinal` starts at 0, so with a `hl-` prefix, this gives `hl-0-1` as a starting point.

Fixes #9567
2022-02-25 17:22:43 +01:00
Bjørn Erik Pedersen 08fdca9d93 Add Markdown diagrams and render hooks for code blocks
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-24 18:59:50 +01:00
Helder Pereira 7a15edafe2 highlight: Add tabindex when code is not highlighted 2021-08-23 12:28:45 +02:00
rhymes f27e542442
markup: Add tabindex="0" to default <pre> wrapper
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-15 16:48:39 +02:00
Cameron Moore 14bce18a6c highlight: Avoid making unnecessary allocation
Avoid creating a local copy of the highlight configuration when no
options are passed.

Benchmarks of building the docs site:

name        old time/op    new time/op    delta
DocsSite-2     1.94s ± 4%     1.93s ± 4%    ~     (p=0.841 n=5+5)

name        old alloc/op   new alloc/op   delta
DocsSite-2     666MB ± 1%     656MB ± 0%  -1.48%  (p=0.008 n=5+5)

name        old allocs/op  new allocs/op  delta
DocsSite-2     8.85M ± 0%     8.76M ± 0%  -1.04%  (p=0.029 n=4+4)
2020-10-16 21:14:02 +02:00
satotake 3c568ad013
markup/highlight: Fix chroma highlight
* Use chroma.Coalesce
* Escape code strings if lexer is nil

Fixes #6877
Fixes #6856
2020-02-17 14:59:26 +01:00
Bjørn Erik Pedersen 40a092b068 markup: Reimplement pygmentsCodefencesGuessSyntax
Fixes #6565
2019-12-02 14:12:23 +01:00
Bjørn Erik Pedersen a2d77f4a80
markup/highlight: Replace the temp for with a dependency 2019-11-24 13:59:16 +01:00
Cameron Moore 20f351ee4c Minor cleanups
Use fmt.Fprint were appropriate instead of Fprintf.  Remove some unused
code.
2019-11-23 16:38:02 +01:00
Bjørn Erik Pedersen bfb9613a14
Add Goldmark as the new default markdown handler
This commit adds the fast and CommonMark compliant Goldmark as the new default markdown handler in Hugo.

If you want to continue using BlackFriday as the default for md/markdown extensions, you can use this configuration:

```toml
[markup]
defaultMarkdownHandler="blackfriday"
```

Fixes #5963
Fixes #1778
Fixes #6355
2019-11-23 14:12:24 +01:00