File tree 6 files changed +22
-5
lines changed
docs/content/doc/advanced
6 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -1985,6 +1985,15 @@ PATH =
1985
1985
; ; Show template execution time in the footer
1986
1986
; SHOW_FOOTER_TEMPLATE_LOAD_TIME = true
1987
1987
1988
+
1989
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1990
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1991
+ ; [markup]
1992
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1993
+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1994
+ ; ; Set the maximum number of characters in a mermaid source. (Set to -1 to disable limits)
1995
+ ; MERMAID_MAX_SOURCE_CHARACTERS = 5000
1996
+
1988
1997
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1989
1998
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1990
1999
; [markup.sanitizer.1]
Original file line number Diff line number Diff line change @@ -882,6 +882,8 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
882
882
883
883
## Markup (` markup ` )
884
884
885
+ - ` MERMAID_MAX_SOURCE_CHARACTERS ` : ** 5000** : Set the maximum size of a Mermaid source. (Set to -1 to disable)
886
+
885
887
Gitea can support Markup using external tools. The example below will add a markup named ` asciidoc ` .
886
888
887
889
``` ini
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ import (
15
15
16
16
// ExternalMarkupRenderers represents the external markup renderers
17
17
var (
18
- ExternalMarkupRenderers []* MarkupRenderer
19
- ExternalSanitizerRules []MarkupSanitizerRule
18
+ ExternalMarkupRenderers []* MarkupRenderer
19
+ ExternalSanitizerRules []MarkupSanitizerRule
20
+ MermaidMaxSourceCharacters int
20
21
)
21
22
22
23
// MarkupRenderer defines the external parser configured in ini
@@ -40,6 +41,7 @@ type MarkupSanitizerRule struct {
40
41
}
41
42
42
43
func newMarkup () {
44
+ MermaidMaxSourceCharacters = Cfg .Section ("markup" ).Key ("MERMAID_MAX_SOURCE_CHARACTERS" ).MustInt (5000 )
43
45
ExternalMarkupRenderers = make ([]* MarkupRenderer , 0 , 10 )
44
46
ExternalSanitizerRules = make ([]MarkupSanitizerRule , 0 , 10 )
45
47
Original file line number Diff line number Diff line change @@ -390,6 +390,9 @@ func NewFuncMap() []template.FuncMap {
390
390
html += "</span>"
391
391
return template .HTML (html )
392
392
},
393
+ "MermaidMaxSourceCharacters" : func () int {
394
+ return setting .MermaidMaxSourceCharacters
395
+ },
393
396
}}
394
397
}
395
398
Original file line number Diff line number Diff line change 60
60
{{ end }}
61
61
]).values()),
62
62
{{end}}
63
+ MermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
63
64
};
64
65
</script>
65
66
<link rel="icon" href="{{AssetUrlPrefix}}/img/logo.svg" type="image/svg+xml">
Original file line number Diff line number Diff line change 1
- const MAX_SOURCE_CHARACTERS = 5000 ;
1
+ const { MermaidMaxSourceCharacters } = window . config ;
2
2
3
3
function displayError ( el , err ) {
4
4
el . closest ( 'pre' ) . classList . remove ( 'is-loading' ) ;
@@ -26,8 +26,8 @@ export async function renderMermaid(els) {
26
26
} ) ;
27
27
28
28
for ( const el of els ) {
29
- if ( el . textContent . length > MAX_SOURCE_CHARACTERS ) {
30
- displayError ( el , new Error ( `Mermaid source of ${ el . textContent . length } characters exceeds the maximum allowed length of ${ MAX_SOURCE_CHARACTERS } .` ) ) ;
29
+ if ( MermaidMaxSourceCharacters >= 0 && el . textContent . length > MermaidMaxSourceCharacters ) {
30
+ displayError ( el , new Error ( `Mermaid source of ${ el . textContent . length } characters exceeds the maximum allowed length of ${ MermaidMaxSourceCharacters } .` ) ) ;
31
31
continue ;
32
32
}
33
33
You can’t perform that action at this time.
0 commit comments