summaryrefslogtreecommitdiffstats
path: root/modules/markup/common
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-01-20 18:46:10 +0100
committerGitHub <noreply@github.com>2022-01-20 18:46:10 +0100
commit54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch)
tree1be12fb072625c1b896b9d72f7912b018aad502b /modules/markup/common
parent1d98d205f5825f40110e6628b61a97c91ac7f72d (diff)
downloadgitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz
gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip
format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
Diffstat (limited to 'modules/markup/common')
-rw-r--r--modules/markup/common/footnote.go11
-rw-r--r--modules/markup/common/html.go14
-rw-r--r--modules/markup/common/linkify.go18
3 files changed, 19 insertions, 24 deletions
diff --git a/modules/markup/common/footnote.go b/modules/markup/common/footnote.go
index 92a54101f0..7b6c57f927 100644
--- a/modules/markup/common/footnote.go
+++ b/modules/markup/common/footnote.go
@@ -178,8 +178,7 @@ func NewFootnoteList() *FootnoteList {
var footnoteListKey = parser.NewContextKey()
-type footnoteBlockParser struct {
-}
+type footnoteBlockParser struct{}
var defaultFootnoteBlockParser = &footnoteBlockParser{}
@@ -265,8 +264,7 @@ func (b *footnoteBlockParser) CanAcceptIndentedLine() bool {
return false
}
-type footnoteParser struct {
-}
+type footnoteParser struct{}
var defaultFootnoteParser = &footnoteParser{}
@@ -337,8 +335,7 @@ func (s *footnoteParser) Parse(parent ast.Node, block text.Reader, pc parser.Con
return NewFootnoteLink(index, name)
}
-type footnoteASTTransformer struct {
-}
+type footnoteASTTransformer struct{}
var defaultFootnoteASTTransformer = &footnoteASTTransformer{}
@@ -357,7 +354,7 @@ func (a *footnoteASTTransformer) Transform(node *ast.Document, reader text.Reade
}
pc.Set(footnoteListKey, nil)
for footnote := list.FirstChild(); footnote != nil; {
- var container ast.Node = footnote
+ container := footnote
next := footnote.NextSibling()
if fc := container.LastChild(); fc != nil && ast.IsParagraph(fc) {
container = fc
diff --git a/modules/markup/common/html.go b/modules/markup/common/html.go
index 3a47686f1e..a2328a2288 100644
--- a/modules/markup/common/html.go
+++ b/modules/markup/common/html.go
@@ -8,12 +8,10 @@ import (
"mvdan.cc/xurls/v2"
)
-var (
- // NOTE: All below regex matching do not perform any extra validation.
- // Thus a link is produced even if the linked entity does not exist.
- // While fast, this is also incorrect and lead to false positives.
- // TODO: fix invalid linking issue
+// NOTE: All below regex matching do not perform any extra validation.
+// Thus a link is produced even if the linked entity does not exist.
+// While fast, this is also incorrect and lead to false positives.
+// TODO: fix invalid linking issue
- // LinkRegex is a regexp matching a valid link
- LinkRegex, _ = xurls.StrictMatchingScheme("https?://")
-)
+// LinkRegex is a regexp matching a valid link
+var LinkRegex, _ = xurls.StrictMatchingScheme("https?://")
diff --git a/modules/markup/common/linkify.go b/modules/markup/common/linkify.go
index 8a4b2a8985..2140486a30 100644
--- a/modules/markup/common/linkify.go
+++ b/modules/markup/common/linkify.go
@@ -20,8 +20,7 @@ import (
var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}((?:/|[#?])[-a-zA-Z0-9@:%_\+.~#!?&//=\(\);,'">\^{}\[\]` + "`" + `]*)?`)
-type linkifyParser struct {
-}
+type linkifyParser struct{}
var defaultLinkifyParser = &linkifyParser{}
@@ -36,10 +35,12 @@ func (s *linkifyParser) Trigger() []byte {
return []byte{' ', '*', '_', '~', '('}
}
-var protoHTTP = []byte("http:")
-var protoHTTPS = []byte("https:")
-var protoFTP = []byte("ftp:")
-var domainWWW = []byte("www.")
+var (
+ protoHTTP = []byte("http:")
+ protoHTTPS = []byte("https:")
+ protoFTP = []byte("ftp:")
+ domainWWW = []byte("www.")
+)
func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
if pc.IsInLinkLabel() {
@@ -58,7 +59,7 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont
var m []int
var protocol []byte
- var typ ast.AutoLinkType = ast.AutoLinkURL
+ typ := ast.AutoLinkURL
if bytes.HasPrefix(line, protoHTTP) || bytes.HasPrefix(line, protoHTTPS) || bytes.HasPrefix(line, protoFTP) {
m = LinkRegex.FindSubmatchIndex(line)
}
@@ -139,8 +140,7 @@ func (s *linkifyParser) CloseBlock(parent ast.Node, pc parser.Context) {
// nothing to do
}
-type linkify struct {
-}
+type linkify struct{}
// Linkify is an extension that allow you to parse text that seems like a URL.
var Linkify = &linkify{}