I'm trying to convert text from Jira to markdown, but I run into a problem when trying to convert links and text color:
{color:red}text in red{color}to<span style="color:red">text in red</span>[Google|http://google.com]to[Google](http://google.com)
The problem with color is that i want to leave color variable (this only would work for red color).
Here is my code, it works, but it's probably not the best way to solve the problem:
import re
conversion_dict = {
r"\]": ")",
r"\|": "](",
r"{color:red}": "<span style=\"color:red\">",
r"{color}": "</span>"
}
def format_text_from_jira(comment_body):
for pattern in conversion_dict:
comment_body = re.sub(pattern, conversion_dict[pattern], comment_body)
return comment_body
Does anyone know better solution?