Fix markdown render behaviors (#34122)

* Fix #27645
* Add config options `MATH_CODE_BLOCK_DETECTION`, problematic syntaxes
are disabled by default
* Fix #33639
    * Add config options `RENDER_OPTIONS_*`, old behaviors are kept
This commit is contained in:
wxiaoguang 2025-04-05 11:56:48 +08:00 committed by GitHub
parent ee6929d96b
commit e1c2d05bde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 418 additions and 222 deletions

View file

@ -8,6 +8,7 @@ import (
"fmt"
"io"
"net/url"
"strconv"
"strings"
"time"
@ -46,7 +47,7 @@ type RenderOptions struct {
// user&repo, format&style&regexp (for external issue pattern), teams&org (for mention)
// RefTypeNameSubURL (for iframe&asciicast)
// markupAllowShortIssuePattern
// markdownLineBreakStyle (comment, document)
// markdownNewLineHardBreak
Metas map[string]string
// used by external render. the router "/org/repo/render/..." will output the rendered content in a standalone page
@ -247,7 +248,8 @@ func Init(renderHelpFuncs *RenderHelperFuncs) {
}
func ComposeSimpleDocumentMetas() map[string]string {
return map[string]string{"markdownLineBreakStyle": "document"}
// TODO: there is no separate config option for "simple document" rendering, so temporarily use the same config as "repo file"
return map[string]string{"markdownNewLineHardBreak": strconv.FormatBool(setting.Markdown.RenderOptionsRepoFile.NewLineHardBreak)}
}
type TestRenderHelper struct {