Fix bug with newlines markdown converter (#1925)

# What this PR does

This PR fixes the bug when new lines were ignored for the existing
templates


## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
Ildar Iskhakov 2023-05-12 11:26:08 +08:00 committed by GitHub
parent 56e7ab9112
commit ae5c4d368f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 23 deletions

View file

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix bug in the "You're Going Oncall" push notification copy by @joeyorlando ([#1922](https://github.com/grafana/oncall/pull/1922))
- Fix bug with newlines in markdown converter ([#1925](https://github.com/grafana/oncall/pull/1925))
## v1.2.21 (2023-05-09)

View file

@ -160,6 +160,10 @@ def convert_slack_md_to_html(text):
def convert_md_to_html(text):
# Markdown expects two or more spaces at the end of a line to indicate a line break.
# Adding two spaces to any line break to support templates that were built without this in mind.
# https://daringfireball.net/projects/markdown/syntax#p
text = text.replace("\n", " \n")
text = markdown2.markdown(
text,
extras=[

View file

@ -149,17 +149,17 @@ tests = {
},
"web": {
"title": "KubeJobCompletion",
"message": """<p><strong>Status</strong>: firing
<strong>Labels:</strong>
<em>job</em>: kube-state-metrics
<em>instance</em>: 10.143.139.7:8443
<em>job_name</em>: email-tracking-perform-initialization-1.0.50
<em>severity</em>: warning
<em>alertname</em>: KubeJobCompletion
<em>namespace</em>: default
<em>prometheus</em>: monitoring/k8s
<strong>Annotations:</strong>
<em>message</em>: Job default/email-tracking-perform-initialization-1.0.50 is taking more than one hour to complete.
"message": """<p><strong>Status</strong>: firing <br/>
<strong>Labels:</strong> <br/>
<em>job</em>: kube-state-metrics <br/>
<em>instance</em>: 10.143.139.7:8443 <br/>
<em>job_name</em>: email-tracking-perform-initialization-1.0.50 <br/>
<em>severity</em>: warning <br/>
<em>alertname</em>: KubeJobCompletion <br/>
<em>namespace</em>: default <br/>
<em>prometheus</em>: monitoring/k8s <br/>
<strong>Annotations:</strong> <br/>
<em>message</em>: Job default/email-tracking-perform-initialization-1.0.50 is taking more than one hour to complete. <br/>
<em>runbook_url</em>: <a href="https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubejobcompletion" rel="nofollow noopener" target="_blank">here</a></p>""", # noqa
"image_url": None,
},

View file

@ -170,18 +170,18 @@ tests = {
"web": {
"title": "KubeJobCompletion",
"message": """\
<p><strong>Status</strong>: firing
<strong>Labels:</strong>
<em>job</em>: kube-state-metrics
<em>instance</em>: 10.143.139.7:8443
<em>job_name</em>: email-tracking-perform-initialization-1.0.50
<em>severity</em>: warning
<em>alertname</em>: KubeJobCompletion
<em>namespace</em>: default
<em>prometheus</em>: monitoring/k8s
<strong>Annotations:</strong>
<em>message</em>: Job default/email-tracking-perform-initialization-1.0.50 is taking more than one hour to complete.
<em>runbook_url</em>: <a href="https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubejobcompletion" rel="nofollow noopener" target="_blank">here</a></p>""", # noqa
<p><strong>Status</strong>: firing <br/>
<strong>Labels:</strong> <br/>
<em>job</em>: kube-state-metrics <br/>
<em>instance</em>: 10.143.139.7:8443 <br/>
<em>job_name</em>: email-tracking-perform-initialization-1.0.50 <br/>
<em>severity</em>: warning <br/>
<em>alertname</em>: KubeJobCompletion <br/>
<em>namespace</em>: default <br/>
<em>prometheus</em>: monitoring/k8s <br/>
<strong>Annotations:</strong> <br/>
<em>message</em>: Job default/email-tracking-perform-initialization-1.0.50 is taking more than one hour to complete. <br/>
<em>runbook_url</em>: <a href="https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubejobcompletion" rel="nofollow noopener" target="_blank">here</a> </p>""", # noqa
"image_url": None,
},
"sms": {