mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Change markdown rendering from blackfriday to goldmark (#9533)
* Move to goldmark Markdown rendering moved from blackfriday to the goldmark. Multiple subtle changes required to the goldmark extensions to keep current rendering and defaults. Can go further with goldmark linkify and have this work within markdown rendering making the link processor unnecessary. Need to think about how to go about allowing extensions - at present it seems that these would be hard to do without recompilation. * linter fixes Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		
							
								
								
									
										50
									
								
								vendor/github.com/yuin/goldmark/parser/emphasis.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								vendor/github.com/yuin/goldmark/parser/emphasis.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| package parser | ||||
|  | ||||
| import ( | ||||
| 	"github.com/yuin/goldmark/ast" | ||||
| 	"github.com/yuin/goldmark/text" | ||||
| ) | ||||
|  | ||||
| type emphasisDelimiterProcessor struct { | ||||
| } | ||||
|  | ||||
| func (p *emphasisDelimiterProcessor) IsDelimiter(b byte) bool { | ||||
| 	return b == '*' || b == '_' | ||||
| } | ||||
|  | ||||
| func (p *emphasisDelimiterProcessor) CanOpenCloser(opener, closer *Delimiter) bool { | ||||
| 	return opener.Char == closer.Char | ||||
| } | ||||
|  | ||||
| func (p *emphasisDelimiterProcessor) OnMatch(consumes int) ast.Node { | ||||
| 	return ast.NewEmphasis(consumes) | ||||
| } | ||||
|  | ||||
| var defaultEmphasisDelimiterProcessor = &emphasisDelimiterProcessor{} | ||||
|  | ||||
| type emphasisParser struct { | ||||
| } | ||||
|  | ||||
| var defaultEmphasisParser = &emphasisParser{} | ||||
|  | ||||
| // NewEmphasisParser return a new InlineParser that parses emphasises. | ||||
| func NewEmphasisParser() InlineParser { | ||||
| 	return defaultEmphasisParser | ||||
| } | ||||
|  | ||||
| func (s *emphasisParser) Trigger() []byte { | ||||
| 	return []byte{'*', '_'} | ||||
| } | ||||
|  | ||||
| func (s *emphasisParser) Parse(parent ast.Node, block text.Reader, pc Context) ast.Node { | ||||
| 	before := block.PrecendingCharacter() | ||||
| 	line, segment := block.PeekLine() | ||||
| 	node := ScanDelimiter(line, before, 1, defaultEmphasisDelimiterProcessor) | ||||
| 	if node == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	node.Segment = segment.WithStop(segment.Start + node.OriginalLength) | ||||
| 	block.Advance(node.OriginalLength) | ||||
| 	pc.PushDelimiter(node) | ||||
| 	return node | ||||
| } | ||||
		Reference in New Issue
	
	Block a user