-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Need to linkify during Markdown rendering (#5066)
* fix: Need to linkify during Markdown rendering * Don't depend on mdx_linkify * Also linkify IETF docs as part of the Markdown conversion * Add test case * Disable automatic links via angle brackets for email addresses * Inline the markdown test files
- Loading branch information
1 parent
35f1d21
commit ac0b9ae
Showing
2 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright The IETF Trust 2023, All Rights Reserved | ||
"""Markdown API utilities tests""" | ||
|
||
from textwrap import dedent | ||
|
||
from ietf.utils.tests import TestCase | ||
from ietf.utils.markdown import markdown | ||
|
||
|
||
class MarkdownTests(TestCase): | ||
SAMPLE_MARKDOWN = dedent( | ||
""" | ||
# IETF Markdown Test File | ||
This file contains a bunch of constructs to test our markdown converter in | ||
`ietf/utils/markdown.py`. | ||
## Links | ||
* https://example.com | ||
* <https://example.com> | ||
* [Example](https://example.com) | ||
* [email protected] | ||
* <[email protected]> | ||
* [User](mailto:[email protected]) | ||
* RFC2119 | ||
* BCP 3 | ||
* STD 1 | ||
* FYI2 | ||
* draft-ietf-opsec-indicators-of-compromise | ||
* draft-ietf-opsec-indicators-of-compromise-01 | ||
""" | ||
) | ||
|
||
SAMPLE_MARKDOWN_OUTPUT = dedent( | ||
""" | ||
<h1 id="ietf-markdown-test-file">IETF Markdown Test File</h1> | ||
<p>This file contains a bunch of constructs to test our markdown converter in<br> | ||
<code>ietf/utils/<a href="http://markdown.py">markdown.py</a></code>.</p> | ||
<h2 id="links">Links</h2> | ||
<ul> | ||
<li><a href="https://example.com">https://example.com</a></li> | ||
<li><a href="https://example.com">https://example.com</a></li> | ||
<li><a href="https://example.com">Example</a></li> | ||
<li><a href="mailto:[email protected]">[email protected]</a></li> | ||
<li><<a href="mailto:[email protected]">[email protected]</a>></li> | ||
<li><a href="mailto:[email protected]">User</a></li> | ||
<li>RFC2119</li> | ||
<li>BCP 3</li> | ||
<li>STD 1</li> | ||
<li>FYI2</li> | ||
<li>draft-ietf-opsec-indicators-of-compromise</li> | ||
<li>draft-ietf-opsec-indicators-of-compromise-01</li> | ||
</ul> | ||
""" | ||
).strip() | ||
|
||
def test_markdown(self): | ||
result = markdown(self.SAMPLE_MARKDOWN) | ||
self.assertEqual(result, self.SAMPLE_MARKDOWN_OUTPUT) |