|
|
@ -23,6 +23,11 @@ func TestAttention(t *testing.T) {
|
|
|
|
defer svg.MockIcon("octicon-alert")()
|
|
|
|
defer svg.MockIcon("octicon-alert")()
|
|
|
|
defer svg.MockIcon("octicon-stop")()
|
|
|
|
defer svg.MockIcon("octicon-stop")()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test := func(input, expected string) {
|
|
|
|
|
|
|
|
result, err := markdown.RenderString(markup.NewTestRenderContext(), input)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(result)))
|
|
|
|
|
|
|
|
}
|
|
|
|
renderAttention := func(attention, icon string) string {
|
|
|
|
renderAttention := func(attention, icon string) string {
|
|
|
|
tmpl := `<blockquote class="attention-header attention-{attention}"><p><svg class="attention-icon attention-{attention} svg {icon}" width="16" height="16"></svg><strong class="attention-{attention}">{Attention}</strong></p>`
|
|
|
|
tmpl := `<blockquote class="attention-header attention-{attention}"><p><svg class="attention-icon attention-{attention} svg {icon}" width="16" height="16"></svg><strong class="attention-{attention}">{Attention}</strong></p>`
|
|
|
|
tmpl = strings.ReplaceAll(tmpl, "{attention}", attention)
|
|
|
|
tmpl = strings.ReplaceAll(tmpl, "{attention}", attention)
|
|
|
@ -31,12 +36,6 @@ func TestAttention(t *testing.T) {
|
|
|
|
return tmpl
|
|
|
|
return tmpl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
test := func(input, expected string) {
|
|
|
|
|
|
|
|
result, err := markdown.RenderString(markup.NewTestRenderContext(), input)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(result)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test(`
|
|
|
|
test(`
|
|
|
|
> [!NOTE]
|
|
|
|
> [!NOTE]
|
|
|
|
> text
|
|
|
|
> text
|
|
|
@ -53,4 +52,7 @@ func TestAttention(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
// legacy GitHub style
|
|
|
|
// legacy GitHub style
|
|
|
|
test(`> **warning**`, renderAttention("warning", "octicon-alert")+"\n</blockquote>")
|
|
|
|
test(`> **warning**`, renderAttention("warning", "octicon-alert")+"\n</blockquote>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// edge case (it used to cause panic)
|
|
|
|
|
|
|
|
test(">\ntext", "<blockquote>\n</blockquote>\n<p>text</p>")
|
|
|
|
}
|
|
|
|
}
|
|
|
|