mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Update test case for auto heading ID generation
- remove WithIDs option - add test cases with international characters and other conditions
This commit is contained in:
parent
2f7a4aa9c4
commit
e6747ee628
1 changed files with 17 additions and 5 deletions
|
|
@ -71,17 +71,29 @@ func (s *myIDs) Put(value []byte) {
|
|||
}
|
||||
|
||||
func TestAutogeneratedIDs(t *testing.T) {
|
||||
ctx := parser.NewContext(parser.WithIDs(&myIDs{}))
|
||||
ctx := parser.NewContext()
|
||||
markdown := New(WithParserOptions(parser.WithAutoHeadingID()))
|
||||
source := []byte("# Title1\n## Title2")
|
||||
|
||||
source := []byte("## Não há quem goste de dor")
|
||||
var b bytes.Buffer
|
||||
err := markdown.Convert(source, &b, parser.WithContext(ctx))
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
if b.String() != `<h1 id="my-id">Title1</h1>
|
||||
<h2 id="my-id">Title2</h2>
|
||||
` {
|
||||
if b.String() != `<h2 id="não-há-quem-goste-de-dor">Não há quem goste de dor</h2>
|
||||
` {
|
||||
t.Errorf("%s\n---------\n%s", source, b.String())
|
||||
}
|
||||
|
||||
source = []byte("## 봄 꿀밤 단 꿀밤 v1.0 (2019년-1월-1일)\n### 가을 꿀밤 안단 꿀밤 v2.0 (2020년_12월_31일)")
|
||||
var b2 bytes.Buffer
|
||||
err = markdown.Convert(source, &b2, parser.WithContext(ctx))
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
if b2.String() != `<h2 id="봄-꿀밤-단-꿀밤-v1-0-2019년-1월-1일">봄 꿀밤 단 꿀밤 v1.0 (2019년-1월-1일)</h2>
|
||||
<h3 id="가을-꿀밤-안단-꿀밤-v2-0-2020년-12월-31일">가을 꿀밤 안단 꿀밤 v2.0 (2020년_12월_31일)</h3>
|
||||
` {
|
||||
t.Errorf("%s\n---------\n%s", source, b2.String())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue