|
|
@@ -29,15 +29,18 @@ func IsIPythonNotebook(name string) bool {
|
|
|
return strings.HasSuffix(name, ".ipynb")
|
|
|
}
|
|
|
|
|
|
+// Issue name style
|
|
|
const (
|
|
|
- ISSUE_NAME_STYLE_NUMERIC = "numeric"
|
|
|
- ISSUE_NAME_STYLE_ALPHANUMERIC = "alphanumeric"
|
|
|
+ IssueNameStyleNumeric = "numeric"
|
|
|
+ IssueNameStyleAlphaNumeric = "alphanumeric"
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
// MentionPattern matches string that mentions someone, e.g. @yoginth
|
|
|
- MentionPattern = regexp.MustCompile(`(\s|^|\W)@[0-9a-zA-Z-_\.]+`)
|
|
|
- CommitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
|
|
|
+ MentionPattern = regexp.MustCompile(`(\s|^|\W)@[0-9a-zA-Z-_\.]+`)
|
|
|
+ // CommitPattern matches string that commits
|
|
|
+ CommitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
|
|
|
+ // IssueFullPattern matches string that issue
|
|
|
IssueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
|
|
|
// IssueNumericPattern matches string that references to a numeric issue, e.g. #505
|
|
|
IssueNumericPattern = regexp.MustCompile(`( |^|\(|\[)#[0-9]+\b`)
|
|
|
@@ -46,9 +49,7 @@ var (
|
|
|
// CrossReferenceIssueNumericPattern matches string that references a numeric issue in a difference repository
|
|
|
// e.g. gitote/gitote#12345
|
|
|
CrossReferenceIssueNumericPattern = regexp.MustCompile(`( |^)[0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+#[0-9]+\b`)
|
|
|
-
|
|
|
- // FIXME: this pattern matches pure numbers as well, right now we do a hack to check in RenderSha1CurrentPattern by converting string to a number.
|
|
|
- // by converting string to a number.
|
|
|
+ // Sha1CurrentPattern by converting string to a number.
|
|
|
Sha1CurrentPattern = regexp.MustCompile(`\b[0-9a-f]{7,40}\b`)
|
|
|
)
|
|
|
|
|
|
@@ -85,7 +86,7 @@ func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string
|
|
|
urlPrefix = cutoutVerbosePrefix(urlPrefix)
|
|
|
|
|
|
pattern := IssueNumericPattern
|
|
|
- if metas["style"] == ISSUE_NAME_STYLE_ALPHANUMERIC {
|
|
|
+ if metas["style"] == IssueNameStyleAlphaNumeric {
|
|
|
pattern = IssueAlphanumericPattern
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +101,7 @@ func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string
|
|
|
link = fmt.Sprintf(`<a href="%s/issues/%s">%s</a>`, urlPrefix, m[1:], m)
|
|
|
} else {
|
|
|
// Support for external issue tracker
|
|
|
- if metas["style"] == ISSUE_NAME_STYLE_ALPHANUMERIC {
|
|
|
+ if metas["style"] == IssueNameStyleAlphaNumeric {
|
|
|
metas["index"] = string(m)
|
|
|
} else {
|
|
|
metas["index"] = string(m[1:])
|
|
|
@@ -306,8 +307,10 @@ OUTER_LOOP:
|
|
|
return rawHTML
|
|
|
}
|
|
|
|
|
|
+// Type holds type
|
|
|
type Type string
|
|
|
|
|
|
+// Markup
|
|
|
const (
|
|
|
UNRECOGNIZED Type = "unrecognized"
|
|
|
MARKDOWN Type = "markdown"
|