| 1 |
package attributes_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/gohugoio/hugo/hugolib" |
| 7 |
) |
| 8 |
|
| 9 |
func TestDescriptionListAutoID(t *testing.T) { |
| 10 |
t.Parallel() |
| 11 |
|
| 12 |
files := ` |
| 13 |
-- hugo.toml -- |
| 14 |
[markup.goldmark.parser] |
| 15 |
autoHeadingID = true |
| 16 |
autoDefinitionTermID = true |
| 17 |
autoIDType = 'github-ascii' |
| 18 |
-- content/p1.md -- |
| 19 |
--- |
| 20 |
title: "Title" |
| 21 |
--- |
| 22 |
|
| 23 |
## Title with id set {#title-with-id} |
| 24 |
|
| 25 |
## Title with id set duplicate {#title-with-id} |
| 26 |
|
| 27 |
## My Title |
| 28 |
|
| 29 |
Base Name |
| 30 |
: Base name of the file. |
| 31 |
|
| 32 |
Base Name |
| 33 |
: Duplicate term name. |
| 34 |
|
| 35 |
My Title |
| 36 |
: Term with same name as title. |
| 37 |
|
| 38 |
Foo@Bar |
| 39 |
: The foo bar. |
| 40 |
|
| 41 |
foo [something](/a/b/) bar |
| 42 |
: A foo bar. |
| 43 |
|
| 44 |
良善天父 |
| 45 |
: The good father. |
| 46 |
|
| 47 |
Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď |
| 48 |
: Testing accents. |
| 49 |
|
| 50 |
Multiline set text header |
| 51 |
Second line |
| 52 |
--------------- |
| 53 |
|
| 54 |
## Example [hyperlink](https://example.com/) in a header |
| 55 |
|
| 56 |
-- layouts/single.html -- |
| 57 |
{{ .Content }}|Identifiers: {{ .Fragments.Identifiers }}| |
| 58 |
` |
| 59 |
|
| 60 |
b := hugolib.Test(t, files) |
| 61 |
|
| 62 |
b.AssertFileContent("public/p1/index.html", |
| 63 |
`<dt id="base-name">Base Name</dt>`, |
| 64 |
`<dt id="base-name-1">Base Name</dt>`, |
| 65 |
`<dt id="foobar">Foo@Bar</dt>`, |
| 66 |
`<h2 id="my-title">My Title</h2>`, |
| 67 |
`<dt id="foo-something-bar">foo <a href="/a/b/">something</a> bar</dt>`, |
| 68 |
`<h2 id="title-with-id">Title with id set</h2>`, |
| 69 |
`<h2 id="title-with-id">Title with id set duplicate</h2>`, |
| 70 |
`<dt id="my-title-1">My Title</dt>`, |
| 71 |
`<dt id="term">良善天父</dt>`, |
| 72 |
`<dt id="a-a-a-a-a-a-c-c-c-c-c-c-c-c-d">Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď</dt>`, |
| 73 |
`<h2 id="second-line">`, |
| 74 |
`<h2 id="example-hyperlink-in-a-header">`, |
| 75 |
"|Identifiers: [a-a-a-a-a-a-c-c-c-c-c-c-c-c-d base-name base-name-1 example-hyperlink-in-a-header foo-something-bar foobar my-title my-title-1 second-line term title-with-id title-with-id]|", |
| 76 |
) |
| 77 |
} |
| 78 |
|
| 79 |
func TestSolitaryAttributesCrash(t *testing.T) { |
| 80 |
t.Parallel() |
| 81 |
|
| 82 |
files := ` |
| 83 |
-- hugo.toml -- |
| 84 |
[markup.goldmark.parser.attribute] |
| 85 |
block = true |
| 86 |
-- layouts/single.html -- |
| 87 |
Content: {{ .Content }} |
| 88 |
-- content/p1.md -- |
| 89 |
--- |
| 90 |
title: "Title" |
| 91 |
--- |
| 92 |
|
| 93 |
1. a |
| 94 |
|
| 95 |
{.x} |
| 96 |
|
| 97 |
1. b |
| 98 |
|
| 99 |
{.x} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
` |
| 104 |
|
| 105 |
b := hugolib.Test(t, files) |
| 106 |
|
| 107 |
b.AssertFileContent("public/p1/index.html", |
| 108 |
` <li>a</li>`, |
| 109 |
) |
| 110 |
} |