feat: better PDF
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package issue
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
@@ -10,3 +13,23 @@ type Issue struct {
|
||||
gitea.Issue
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
func (i Issue) Shorthand() string {
|
||||
str := i.Repository.Name
|
||||
if strings.Contains(str, "-") {
|
||||
s := strings.Split(str, "-")
|
||||
str = s[len(s)-1]
|
||||
} else if len(str) > 3 {
|
||||
str = str[:3]
|
||||
}
|
||||
return fmt.Sprintf("%s-%d", strings.ToUpper(str), i.Index)
|
||||
}
|
||||
|
||||
func (i Issue) CleanBody() string {
|
||||
reBlock := regexp.MustCompile("(?s)```info(.*?)```(.*)")
|
||||
block := reBlock.FindStringSubmatch(i.Body)
|
||||
if len(block) < 3 {
|
||||
return i.Body
|
||||
}
|
||||
return strings.TrimSpace(block[2])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user