grim/youtrack-import

cdadae07e61c
Parents e344f4ff2c93
Children 156cc34dc505
Convert bold, italic, and bold italic to the markdown version
--- a/trac/tickets.go Tue Aug 04 00:09:24 2020 -0500
+++ b/trac/tickets.go Tue Aug 04 03:03:06 2020 -0500
@@ -109,6 +109,11 @@
// trac's inline code is done via "``" and "{{{}}}", since markdown already
// handles "``" we just need to convert "{{{}}}" to "``"
inlineCodeRegex = regexp.MustCompile(`{{{(.+?)}}}`)
+
+ // bold/italic suck, these deal with it.
+ boldItalicRegex = regexp.MustCompile(`'''''(.+?)'''''`)
+ boldRegex = regexp.MustCompile(`'''(.+?)'''`)
+ italicRegex = regexp.MustCompile(`''(.+?)''`)
)
func convertComment(comment string) string {
@@ -122,6 +127,13 @@
// repalce all [[br]]'s with <br/>
comment = breakRegex.ReplaceAllString(comment, "<br/>")
+ // replace bold italics with 3 *'s because that's how markdown does it...
+ comment = boldItalicRegex.ReplaceAllString(comment, "***$1***")
+ // replace bold with 2 *'s because that's bold in markdown...
+ comment = boldRegex.ReplaceAllString(comment, "**$1**")
+ // replace italic with 1 *'s because that's italic in markdown...
+ comment = italicRegex.ReplaceAllString(comment, "*$1*")
+
return comment
}