grim/youtrack-import

replace [[br]] from trac with <br/>. Fixed YI-33
draft
2020-08-03, Gary Kramlich
6e41a2be36b1
Parents 3fbb1caeed04
Children a2fccfd52984
replace [[br]] from trac with
. Fixed YI-33
--- a/trac/tickets.go Wed Jul 29 01:35:22 2020 -0500
+++ b/trac/tickets.go Mon Aug 03 21:25:44 2020 -0500
@@ -101,6 +101,10 @@
// Also, you can have a code block in a block quote which is why we have
// (?:\> )* to make sure that'll be supported.
commentCodeBlockRegex = regexp.MustCompile(`(?s)((?:^|\r\n)(?:\> )*)(?:\s*{{{\s*)(\r\n.*?)(?: *}}}\s*?)(\r\n|$)`)
+
+ // trac supports [[br]] for an explicit line break, we repalce it with a
+ // <br/> tag.
+ breakRegex = regexp.MustCompile(`(?i)\[\[br\]\]`)
)
func (tc *ticketChange) cleanNewValue() string {
@@ -114,6 +118,9 @@
newComment = commentCodeBlockRegex.ReplaceAllString(newComment, "$1```$2```$3")
}
+ // repalce all [[br]]'s with <br/>
+ newComment = breakRegex.ReplaceAllString(newComment, "<br/>")
+
return newComment
}