grim/youtrack-import
Convert creole links and code to markdown. Fixes YI-24
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bitbucket/creole.go Sun Jan 19 14:03:22 2020 -0600
@@ -0,0 +1,61 @@
+ "hg.sr.ht/~grim/youtrack-import/youtrack" + creoleLinkRegex = regexp.MustCompile(`\[\[(.+?)\|(.+?)\]\]`) + creoleCodeRegex = regexp.MustCompile("```" + `\r\n#!((.*?)\r\n)`) +func replaceCreoleLinks(message string) string { + matches := creoleLinkRegex.FindAllStringSubmatch(message, -1) + for _, match := range matches { + replacement := fmt.Sprintf("[%s](%s)", text, uri) + output = strings.Replace(output, old, replacement, 1) +func replaceCreoleCode(message string) string { + matches := creoleCodeRegex.FindAllStringSubmatch(message, -1) + for _, match := range matches { + replacement := fmt.Sprintf("```%s\n", lang) + output = strings.Replace(output, old, replacement, 1) + fmt.Printf("output: %q\n", output) +func replaceCreole(m map[string]*youtrack.User, message string) string { + output = replaceCreoleLinks(output) + output = replaceCreoleCode(output) --- a/bitbucket/keywords.go Fri Jan 17 23:19:18 2020 -0600
+++ b/bitbucket/keywords.go Sun Jan 19 14:03:22 2020 -0600
@@ -107,5 +107,7 @@
output = replaceChangeSets(repository, output)
output = replaceCommitHashes(repository, output)
+ output = replaceCreole(m, output) --- a/go.mod Fri Jan 17 23:19:18 2020 -0600
+++ b/go.mod Sun Jan 19 14:03:22 2020 -0600
@@ -5,4 +5,5 @@
github.com/alecthomas/kong v0.2.1
github.com/avast/retry-go v2.4.3+incompatible
+ golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9 // indirect --- a/go.sum Fri Jan 17 23:19:18 2020 -0600
+++ b/go.sum Sun Jan 19 14:03:22 2020 -0600
@@ -11,3 +11,17 @@
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9 h1:KOkk4e2xd5OeCDJGwacvr75ICCbCsShrHiqPEdsA9hg= +golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=