File tree Expand file tree Collapse file tree 6 files changed +22
-5
lines changed
docs/content/doc/advanced Expand file tree Collapse file tree 6 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -1985,6 +1985,15 @@ PATH =
19851985; ; Show template execution time in the footer
19861986; SHOW_FOOTER_TEMPLATE_LOAD_TIME = true
19871987
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+
19881997; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19891998; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19901999; [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
882882
883883## Markup (` markup ` )
884884
885+ - ` MERMAID_MAX_SOURCE_CHARACTERS ` : ** 5000** : Set the maximum size of a Mermaid source. (Set to -1 to disable)
886+
885887Gitea can support Markup using external tools. The example below will add a markup named ` asciidoc ` .
886888
887889``` ini
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ import (
1515
1616// ExternalMarkupRenderers represents the external markup renderers
1717var (
18- ExternalMarkupRenderers []* MarkupRenderer
19- ExternalSanitizerRules []MarkupSanitizerRule
18+ ExternalMarkupRenderers []* MarkupRenderer
19+ ExternalSanitizerRules []MarkupSanitizerRule
20+ MermaidMaxSourceCharacters int
2021)
2122
2223// MarkupRenderer defines the external parser configured in ini
@@ -40,6 +41,7 @@ type MarkupSanitizerRule struct {
4041}
4142
4243func newMarkup () {
44+ MermaidMaxSourceCharacters = Cfg .Section ("markup" ).Key ("MERMAID_MAX_SOURCE_CHARACTERS" ).MustInt (5000 )
4345 ExternalMarkupRenderers = make ([]* MarkupRenderer , 0 , 10 )
4446 ExternalSanitizerRules = make ([]MarkupSanitizerRule , 0 , 10 )
4547
Original file line number Diff line number Diff line change @@ -390,6 +390,9 @@ func NewFuncMap() []template.FuncMap {
390390 html += "</span>"
391391 return template .HTML (html )
392392 },
393+ "MermaidMaxSourceCharacters" : func () int {
394+ return setting .MermaidMaxSourceCharacters
395+ },
393396 }}
394397}
395398
Original file line number Diff line number Diff line change 6060 {{ end }}
6161 ]).values()),
6262 {{end}}
63+ MermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
6364 };
6465 </script>
6566 <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 ;
22
33function displayError ( el , err ) {
44 el . closest ( 'pre' ) . classList . remove ( 'is-loading' ) ;
@@ -26,8 +26,8 @@ export async function renderMermaid(els) {
2626 } ) ;
2727
2828 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 } .` ) ) ;
3131 continue ;
3232 }
3333
You can’t perform that action at this time.
0 commit comments