File tree 3 files changed +52
-7
lines changed
3 files changed +52
-7
lines changed Original file line number Diff line number Diff line change 5
5
package structs
6
6
7
7
import (
8
- "path/filepath "
8
+ "path"
9
9
"time"
10
10
)
11
11
@@ -163,11 +163,11 @@ const (
163
163
164
164
// Type returns the type of IssueTemplate, can be "md", "yaml" or empty for known
165
165
func (it IssueTemplate ) Type () IssueTemplateType {
166
- if it .Name == "config.yaml" || it . Name == "config.yml" {
166
+ if base := path . Base ( it .FileName ); base == "config.yaml" || base == "config.yml" {
167
167
// ignore config.yaml which is a special configuration file
168
168
return ""
169
169
}
170
- if ext := filepath .Ext (it .FileName ); ext == ".md" {
170
+ if ext := path .Ext (it .FileName ); ext == ".md" {
171
171
return IssueTemplateTypeMarkdown
172
172
} else if ext == ".yaml" || ext == ".yml" {
173
173
return IssueTemplateTypeYaml
Original file line number Diff line number Diff line change
1
+ // Copyright 2022 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package structs
6
+
7
+ import (
8
+ "testing"
9
+
10
+ "github.com/stretchr/testify/assert"
11
+ )
12
+
13
+ func TestIssueTemplate_Type (t * testing.T ) {
14
+ tests := []struct {
15
+ fileName string
16
+ want IssueTemplateType
17
+ }{
18
+ {
19
+ fileName : ".gitea/ISSUE_TEMPLATE/bug_report.yaml" ,
20
+ want : IssueTemplateTypeYaml ,
21
+ },
22
+ {
23
+ fileName : ".gitea/ISSUE_TEMPLATE/bug_report.md" ,
24
+ want : IssueTemplateTypeMarkdown ,
25
+ },
26
+ {
27
+ fileName : ".gitea/ISSUE_TEMPLATE/bug_report.txt" ,
28
+ want : "" ,
29
+ },
30
+ {
31
+ fileName : ".gitea/ISSUE_TEMPLATE/config.yaml" ,
32
+ want : "" ,
33
+ },
34
+ }
35
+ for _ , tt := range tests {
36
+ t .Run (tt .fileName , func (t * testing.T ) {
37
+ it := IssueTemplate {
38
+ FileName : tt .fileName ,
39
+ }
40
+ assert .Equal (t , tt .want , it .Type ())
41
+ })
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -23,12 +23,14 @@ export async function renderMath() {
23
23
24
24
for ( const el of els ) {
25
25
const source = el . textContent ;
26
- const options = { display : el . classList . contains ( 'display' ) } ;
26
+ const nodeName = el . classList . contains ( 'display' ) ? 'p' : 'span' ;
27
27
28
28
try {
29
- const markup = katex . renderToString ( source , options ) ;
30
- const tempEl = document . createElement ( options . display ? 'p' : 'span' ) ;
31
- tempEl . innerHTML = markup ;
29
+ const tempEl = document . createElement ( nodeName ) ;
30
+ katex . render ( source , tempEl , {
31
+ maxSize : 25 ,
32
+ maxExpand : 50 ,
33
+ } ) ;
32
34
targetElement ( el ) . replaceWith ( tempEl ) ;
33
35
} catch ( error ) {
34
36
displayError ( el , error ) ;
You can’t perform that action at this time.
0 commit comments