Skip to content

Commit

Permalink
markup.ComposeSimpleDocumentMetas
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 15, 2024
1 parent 0ec5c4a commit 0959fcd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions modules/markup/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (ctx *RenderContext) AddCancel(fn func()) {
fn()
}
}

func (ctx *RenderContext) IsContentModeWiki() bool {
return ctx.Metas != nil && ctx.Metas["renderContentMode"] == "wiki"
}
Expand Down Expand Up @@ -227,3 +228,7 @@ func Init(ph *ProcessorHelper) {
}
}
}

func ComposeSimpleDocumentMetas() map[string]string {
return map[string]string{"markdownLineBreakStyle": "document"}
}
2 changes: 1 addition & 1 deletion modules/templates/util_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func reactionToEmoji(reaction string) template.HTML {
func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML { //nolint:revive
output, err := markdown.RenderString(&markup.RenderContext{
Ctx: ut.ctx,
Metas: map[string]string{"mode": "document"},
Metas: markup.ComposeSimpleDocumentMetas(),
}, input)
if err != nil {
log.Error("RenderString: %v", err)
Expand Down
1 change: 0 additions & 1 deletion modules/templates/util_render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var testMetas = map[string]string{
"user": "user13",
"repo": "repo11",
"repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/",
"mode": "comment",
}

func TestMain(m *testing.M) {
Expand Down
2 changes: 1 addition & 1 deletion routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool {
Base: profileDbRepo.Link(),
BranchPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)),
},
Metas: map[string]string{"mode": "document"},
Metas: markup.ComposeSimpleDocumentMetas(),
}, bytes); err != nil {
log.Error("failed to RenderString: %v", err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion routers/web/shared/user/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
ctx.Data["OpenIDs"] = openIDs
if len(ctx.ContextUser.Description) != 0 {
content, err := markdown.RenderString(&markup.RenderContext{
Metas: map[string]string{"mode": "document"},
Metas: markup.ComposeSimpleDocumentMetas(),
Ctx: ctx,
}, ctx.ContextUser.Description)
if err != nil {
Expand Down

0 comments on commit 0959fcd

Please sign in to comment.