-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from OneZoom/issue-781-markdown-in-tours
Issue 781 markdown in tours
- Loading branch information
Showing
6 changed files
with
73 additions
and
6 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
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,21 @@ | ||
from gluon import current | ||
from gluon.contrib.markdown.markdown2 import Markdown | ||
|
||
def markdown(text): | ||
if not hasattr(current, 'oz_markdown'): | ||
current.oz_markdown = Markdown( | ||
safe_mode="escape", | ||
) | ||
|
||
return current.oz_markdown.convert(text) | ||
|
||
if __name__ == '__main__': | ||
import sys | ||
|
||
if current.globalenv['is_testing'] != True: | ||
raise RuntimeError("Do not run tests in production environments, ensure is_testing = True") | ||
suite = unittest.TestSuite() | ||
suite.addTest(unittest.makeSuite(TestEmbed)) | ||
result = unittest.TextTestRunner(verbosity=2).run(suite) | ||
if not result.wasSuccessful(): | ||
sys.exit(1) |
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,42 @@ | ||
""" | ||
Run with:: | ||
./web2py-run tests/unit/test_modules_markdown.py | ||
""" | ||
import re | ||
import unittest | ||
|
||
from gluon.globals import Request | ||
from gluon.http import HTTP | ||
|
||
from applications.OZtree.tests.unit import util | ||
|
||
import markdown | ||
|
||
|
||
class TestMarkdown(unittest.TestCase): | ||
maxDiff = None | ||
|
||
def test_markdown_safemode(self): | ||
"""Raw HTML isn't allowed""" | ||
self.assertEqual(markdown.markdown(""" | ||
*Hello there* | ||
<b>I am in your HTML</b> | ||
""").strip(), """ | ||
<p><em>Hello there</em></p> | ||
<p><b>I am in your HTML</b></p> | ||
""".strip()) | ||
|
||
if __name__ == '__main__': | ||
import sys | ||
|
||
if current.globalenv['is_testing'] != True: | ||
raise RuntimeError("Do not run tests in production environments, ensure is_testing = True") | ||
suite = unittest.TestSuite() | ||
suite.addTest(unittest.makeSuite(TestMarkdown)) | ||
result = unittest.TextTestRunner(verbosity=2).run(suite) | ||
if not result.wasSuccessful(): | ||
sys.exit(1) |
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