mirror of
				https://gitcode.com/gitea/gitea.git
				synced 2025-10-25 12:26:40 +08:00 
			
		
		
		
	 32d9c47ec7
			
		
	
	32d9c47ec7
	
	
	
		
			
			Support RTL content in Markdown:  Example document: https://try.gitea.io/silverwind/symlink-test/src/branch/master/bidi-text.md Same on GitHub: https://github.com/silverwind/symlink-test/blob/master/bidi-text.md `dir=auto` enables a browser heuristic that sets the text direction automatically. It is the only way to get automatic text direction. Ref: https://codeberg.org/Codeberg/Community/issues/1021 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
		
			
				
	
	
		
			34 lines
		
	
	
		
			960 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			960 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2022 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package markup
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"code.gitea.io/gitea/models/user"
 | |
| 	gitea_context "code.gitea.io/gitea/modules/context"
 | |
| 	"code.gitea.io/gitea/modules/markup"
 | |
| )
 | |
| 
 | |
| func ProcessorHelper() *markup.ProcessorHelper {
 | |
| 	return &markup.ProcessorHelper{
 | |
| 		ElementDir: "auto", // set dir="auto" for necessary (eg: <p>, <h?>, etc) tags
 | |
| 		IsUsernameMentionable: func(ctx context.Context, username string) bool {
 | |
| 			mentionedUser, err := user.GetUserByName(ctx, username)
 | |
| 			if err != nil {
 | |
| 				return false
 | |
| 			}
 | |
| 
 | |
| 			giteaCtx, ok := ctx.(*gitea_context.Context)
 | |
| 			if !ok {
 | |
| 				// when using general context, use user's visibility to check
 | |
| 				return mentionedUser.Visibility.IsPublic()
 | |
| 			}
 | |
| 
 | |
| 			// when using gitea context (web context), use user's visibility and user's permission to check
 | |
| 			return user.IsUserVisibleToViewer(giteaCtx, mentionedUser, giteaCtx.Doer)
 | |
| 		},
 | |
| 	}
 | |
| }
 |