Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Tweak katex options (go-gitea#21828)
  Ignore issue template with a special name (go-gitea#21830)
  • Loading branch information
zjjhot committed Nov 17, 2022
2 parents 3581704 + c144942 commit e7bf5f1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/structs/issue.go
Expand Up @@ -5,7 +5,7 @@
package structs

import (
"path/filepath"
"path"
"time"
)

Expand Down Expand Up @@ -163,11 +163,11 @@ const (

// Type returns the type of IssueTemplate, can be "md", "yaml" or empty for known
func (it IssueTemplate) Type() IssueTemplateType {
if it.Name == "config.yaml" || it.Name == "config.yml" {
if base := path.Base(it.FileName); base == "config.yaml" || base == "config.yml" {
// ignore config.yaml which is a special configuration file
return ""
}
if ext := filepath.Ext(it.FileName); ext == ".md" {
if ext := path.Ext(it.FileName); ext == ".md" {
return IssueTemplateTypeMarkdown
} else if ext == ".yaml" || ext == ".yml" {
return IssueTemplateTypeYaml
Expand Down
43 changes: 43 additions & 0 deletions modules/structs/issue_test.go
@@ -0,0 +1,43 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package structs

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestIssueTemplate_Type(t *testing.T) {
tests := []struct {
fileName string
want IssueTemplateType
}{
{
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.yaml",
want: IssueTemplateTypeYaml,
},
{
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.md",
want: IssueTemplateTypeMarkdown,
},
{
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.txt",
want: "",
},
{
fileName: ".gitea/ISSUE_TEMPLATE/config.yaml",
want: "",
},
}
for _, tt := range tests {
t.Run(tt.fileName, func(t *testing.T) {
it := IssueTemplate{
FileName: tt.fileName,
}
assert.Equal(t, tt.want, it.Type())
})
}
}
10 changes: 6 additions & 4 deletions web_src/js/markup/math.js
Expand Up @@ -23,12 +23,14 @@ export async function renderMath() {

for (const el of els) {
const source = el.textContent;
const options = {display: el.classList.contains('display')};
const nodeName = el.classList.contains('display') ? 'p' : 'span';

try {
const markup = katex.renderToString(source, options);
const tempEl = document.createElement(options.display ? 'p' : 'span');
tempEl.innerHTML = markup;
const tempEl = document.createElement(nodeName);
katex.render(source, tempEl, {
maxSize: 25,
maxExpand: 50,
});
targetElement(el).replaceWith(tempEl);
} catch (error) {
displayError(el, error);
Expand Down

0 comments on commit e7bf5f1

Please sign in to comment.