grim/youtrack-import
Clone
Summary
Browse
Changes
Graph
Convert bold, italic, and bold italic to the markdown version
draft
2020-08-04, Gary Kramlich
cdadae07e61c
Convert bold, italic, and bold italic to the markdown version
package
bitbucket
import
(
"regexp"
"keep.imfreedom.org/grim/youtrack-import/youtrack"
)
var
(
creoleLinkRegex
=
regexp
.
MustCompile
(
`\[\[(.+?)\|(.+?)\]\]`
)
creoleCodeRegex
=
regexp
.
MustCompile
(
"```"
+
`\n#!((.*?)\n)`
)
)
func
replaceCreoleLinks
(
message
string
)
string
{
return
creoleLinkRegex
.
ReplaceAllString
(
message
,
"[$2]($1)"
)
}
func
replaceCreoleCode
(
message
string
)
string
{
return
creoleCodeRegex
.
ReplaceAllString
(
message
,
"```$2\n"
)
}
func
replaceCreole
(
m
map
[
string
]
*
youtrack
.
User
,
message
string
)
string
{
output
:=
message
output
=
replaceCreoleLinks
(
output
)
output
=
replaceCreoleCode
(
output
)
return
output
}