Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions markdown/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ class Markdown(object):
'xhtml': to_xhtml_string,
}

block_level_elements = [
# Elements which are invalid to wrap in a `<p>` tag.
# See http://w3c.github.io/html/grouping-content.html#the-p-element
'address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl',
'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
'h4', 'h5', 'h6', 'header', 'hr', 'main', 'menu', 'nav', 'ol', 'p', 'pre',
'section', 'table', 'ul',
# Other elements which Markdown should not be mucking up the contents of.
'canvas', 'dd', 'dt', 'group', 'iframe', 'li', 'math', 'noscript', 'output',
'progress', 'script', 'style', 'tbody', 'td', 'th', 'thead', 'tr', 'video'
]

def __init__(self, **kwargs):
"""
Creates a new Markdown instance.
Expand All @@ -88,6 +76,18 @@ def __init__(self, **kwargs):
self.ESCAPED_CHARS = ['\\', '`', '*', '_', '{', '}', '[', ']',
'(', ')', '>', '#', '+', '-', '.', '!']

self.block_level_elements = [
# Elements which are invalid to wrap in a `<p>` tag.
# See http://w3c.github.io/html/grouping-content.html#the-p-element
'address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl',
'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
'h4', 'h5', 'h6', 'header', 'hr', 'main', 'menu', 'nav', 'ol', 'p', 'pre',
'section', 'table', 'ul',
# Other elements which Markdown should not be mucking up the contents of.
'canvas', 'dd', 'dt', 'group', 'iframe', 'li', 'math', 'noscript', 'output',
'progress', 'script', 'style', 'tbody', 'td', 'th', 'thead', 'tr', 'video'
]

self.registeredExtensions = []
self.docType = ""
self.stripTopLevelTags = True
Expand Down
12 changes: 12 additions & 0 deletions tests/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,18 @@ def testAppend(self):
self.assertEqual('|' not in md2.ESCAPED_CHARS, True)


class TestBlockAppend(unittest.TestCase):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waylan , wasn't sure if you have a special place for new API tests, so I put this with the old.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually testing rendered output, so this is were it belongs.

""" Tests block kHTML append. """

def testBlockAppend(self):
""" Test that appended escapes are only in the current instance. """
md = markdown.Markdown()
md.block_level_elements.append('test')
self.assertEqual('test' in md.block_level_elements, True)
md2 = markdown.Markdown()
self.assertEqual('test' not in md2.block_level_elements, True)


class TestAncestorExclusion(unittest.TestCase):
""" Tests exclusion of tags in ancestor list. """

Expand Down