mirror of https://github.com/zulip/zulip.git
webhooks/freshdesk/doc.md: Remove unescape_rendered_html kludge.
This reverts commit f476ec7fac
(#10312)
and replaces it with a proper fix using Jinja2 raw blocks.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
9f08513acb
commit
5e97e58df3
|
@ -1,5 +0,0 @@
|
|||
header
|
||||
|
||||
{{ render_markdown_path("zerver/tests/markdown/test_unicode_decimals.md", {"unescape_rendered_html": unescape_rendered_html}) }}
|
||||
|
||||
footer
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,4 +1,3 @@
|
|||
from html import unescape
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import markdown
|
||||
|
@ -148,13 +147,4 @@ def render_markdown_path(markdown_file_path: str,
|
|||
html = md_engine.convert(markdown_string)
|
||||
rendered_html = jinja.from_string(html).render(context)
|
||||
|
||||
if context.get('unescape_rendered_html', False):
|
||||
# In some exceptional cases (such as our Freshdesk webhook docs),
|
||||
# code blocks in some of our Markdown templates have characters such
|
||||
# as '{' encoded as '{' to prevent clashes with Jinja2 syntax,
|
||||
# but the encoded form never gets decoded because the text ends up
|
||||
# inside a <pre> tag. So here, we explicitly "unescape" such characters
|
||||
# if 'unescape_rendered_html' is True.
|
||||
rendered_html = unescape(rendered_html)
|
||||
|
||||
return mark_safe(rendered_html)
|
||||
|
|
|
@ -295,22 +295,6 @@ footer
|
|||
self.assertEqual(content_sans_whitespace,
|
||||
expected_html_sans_whitespace)
|
||||
|
||||
def test_encoded_unicode_decimals_in_markdown_template(self) -> None:
|
||||
template = get_template("tests/test_unicode_decimals.html")
|
||||
context = {'unescape_rendered_html': False}
|
||||
content = template.render(context)
|
||||
|
||||
content_sans_whitespace = content.replace(" ", "").replace('\n', '')
|
||||
self.assertEqual(content_sans_whitespace,
|
||||
'header<p>{}</p>footer')
|
||||
|
||||
context = {'unescape_rendered_html': True}
|
||||
content = template.render(context)
|
||||
|
||||
content_sans_whitespace = content.replace(" ", "").replace('\n', '')
|
||||
self.assertEqual(content_sans_whitespace,
|
||||
'header<p>{}</p>footer')
|
||||
|
||||
def test_markdown_nested_code_blocks(self) -> None:
|
||||
template = get_template("tests/test_markdown.html")
|
||||
context = {
|
||||
|
|
|
@ -194,14 +194,6 @@ def integration_doc(request: HttpRequest, integration_name: str=REQ(default=None
|
|||
context['hubot_docs_url'] = integration.hubot_docs_url
|
||||
if isinstance(integration, EmailIntegration):
|
||||
context['email_gateway_example'] = settings.EMAIL_GATEWAY_EXAMPLE
|
||||
if integration.name == 'freshdesk':
|
||||
# In our Freshdesk docs, some nested code blocks have characters such
|
||||
# as '{' encoded as '{' to prevent clashes with Jinja2 syntax,
|
||||
# but the encoded form never gets rendered because the text ends up
|
||||
# inside a <pre> tag. So here, we explicitly set a directive that
|
||||
# a particular template should be "unescaped" before being displayed.
|
||||
# Note that this value is used by render_markdown_path.
|
||||
context['unescape_rendered_html'] = True
|
||||
|
||||
doc_html_str = render_markdown_path(integration.doc, context)
|
||||
|
||||
|
|
|
@ -28,20 +28,22 @@ integration!
|
|||
the following JSON into the **Content** box:
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
{"freshdesk_webhook":
|
||||
{
|
||||
"triggered_event":"{{triggered_event}}",
|
||||
"ticket_id":"{{ticket.id}}",
|
||||
"ticket_url":"{{ticket.url}}",
|
||||
"ticket_type":"{{ticket.ticket_type}}",
|
||||
"ticket_subject":"{{ticket.subject}}",
|
||||
"ticket_description":"{{ticket.description}}",
|
||||
"ticket_status":"{{ticket.status}}",
|
||||
"ticket_priority":"{{ticket.priority}}",
|
||||
"requester_name":"{{ticket.requester.name}}",
|
||||
"requester_email":"{{ticket.requester.email}}",
|
||||
"triggered_event":"{{triggered_event}}",
|
||||
"ticket_id":"{{ticket.id}}",
|
||||
"ticket_url":"{{ticket.url}}",
|
||||
"ticket_type":"{{ticket.ticket_type}}",
|
||||
"ticket_subject":"{{ticket.subject}}",
|
||||
"ticket_description":"{{ticket.description}}",
|
||||
"ticket_status":"{{ticket.status}}",
|
||||
"ticket_priority":"{{ticket.priority}}",
|
||||
"requester_name":"{{ticket.requester.name}}",
|
||||
"requester_email":"{{ticket.requester.email}}",
|
||||
}
|
||||
}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Click **Save**.
|
||||
|
@ -74,20 +76,22 @@ integration!
|
|||
the following JSON into the **Content** box:
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
{"freshdesk_webhook":
|
||||
{
|
||||
"triggered_event":"{{triggered_event}}",
|
||||
"ticket_id":"{{ticket.id}}",
|
||||
"ticket_url":"{{ticket.url}}",
|
||||
"ticket_type":"{{ticket.ticket_type}}",
|
||||
"ticket_subject":"{{ticket.subject}}",
|
||||
"ticket_description":"{{ticket.description}}",
|
||||
"ticket_status":"{{ticket.status}}",
|
||||
"ticket_priority":"{{ticket.priority}}",
|
||||
"requester_name":"{{ticket.requester.name}}",
|
||||
"requester_email":"{{ticket.requester.email}}",
|
||||
"triggered_event":"{{triggered_event}}",
|
||||
"ticket_id":"{{ticket.id}}",
|
||||
"ticket_url":"{{ticket.url}}",
|
||||
"ticket_type":"{{ticket.ticket_type}}",
|
||||
"ticket_subject":"{{ticket.subject}}",
|
||||
"ticket_description":"{{ticket.description}}",
|
||||
"ticket_status":"{{ticket.status}}",
|
||||
"ticket_priority":"{{ticket.priority}}",
|
||||
"requester_name":"{{ticket.requester.name}}",
|
||||
"requester_email":"{{ticket.requester.email}}",
|
||||
}
|
||||
}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Click **Save**.
|
||||
|
|
Loading…
Reference in New Issue