mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 14:31:02 +00:00 
			
		
		
		
	- When math equation support was added into Gitea it allowed for math equations to be typed over multiple lines via `\[ ... \]` and `$$ ... $$`. Specifically the former delimiters caused problems with legitimate markdown input to be seen as a math equation and therefore was disabled in e1a82a15d3.
- Enable this multi-line parsing for wiki as it's less likely to cause issues in the context of the wiki.
- It is hard to fix this issue in a proper way without investing a good amount of time in Goldmark as explained in https://codeberg.org/forgejo/forgejo/issues/6902#issuecomment-2845317
- Added unit test.
- Resolves forgejo/forgejo#6902
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8424
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
		
	
			
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			645 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			645 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2024 The Forgejo Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: GPL-3.0-or-later
 | |
| 
 | |
| package util
 | |
| 
 | |
| import (
 | |
| 	"bytes"
 | |
| 
 | |
| 	"github.com/yuin/goldmark/ast"
 | |
| 	"github.com/yuin/goldmark/parser"
 | |
| )
 | |
| 
 | |
| func textOfChildren(n ast.Node, src []byte, b *bytes.Buffer) {
 | |
| 	for c := n.FirstChild(); c != nil; c = c.NextSibling() {
 | |
| 		if t, ok := c.(*ast.Text); ok {
 | |
| 			b.Write(t.Value(src))
 | |
| 		} else {
 | |
| 			textOfChildren(c, src, b)
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func Text(n ast.Node, src []byte) []byte {
 | |
| 	var b bytes.Buffer
 | |
| 	textOfChildren(n, src, &b)
 | |
| 	return b.Bytes()
 | |
| }
 | |
| 
 | |
| var (
 | |
| 	RenderContextKey = parser.NewContextKey()
 | |
| 	RenderConfigKey  = parser.NewContextKey()
 | |
| )
 |