// Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT package markup_test import ( "regexp" "testing" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/test" "github.com/stretchr/testify/assert" ) func TestToCWithHTML(t *testing.T) { defer test.MockVariableValue(&markup.RenderBehaviorForTesting.DisableAdditionalAttributes, true)() t1 := `tag link and Bold` t2 := "code block ``" t3 := "markdown **bold**" input := `--- include_toc: true --- # ` + t1 + ` ## ` + t2 + ` #### ` + t3 + ` ## last ` renderCtx := markup.NewTestRenderContext().WithEnableHeadingIDGeneration(true) resultHTML, err := markdown.RenderString(renderCtx, input) assert.NoError(t, err) result := string(resultHTML) re := regexp.MustCompile(`(?s)
.*?
`) result = re.ReplaceAllString(result, "\n") expected := `
toc

tag link and Bold

code block <a>

markdown bold

last

` assert.Equal(t, expected, result) }