summaryrefslogtreecommitdiff
path: root/markdown/extensions/admonition.py
diff options
context:
space:
mode:
authorIsaac Muse <faceless.shop@gmail.com>2021-02-05 13:25:45 -0700
committerGitHub <noreply@github.com>2021-02-05 15:25:45 -0500
commit0e6dc4c4f5dc8d6691eb95549657034f6d9abcb6 (patch)
treedcbc44dc186537d388a65335c568fe6ae7b14f1a /markdown/extensions/admonition.py
parent49e1d29d791926229e2bbafd8132666d74d14883 (diff)
downloadpython-markdown-0e6dc4c4f5dc8d6691eb95549657034f6d9abcb6.tar.gz
Ensure admonition content is detabbed properly
Diffstat (limited to 'markdown/extensions/admonition.py')
-rw-r--r--markdown/extensions/admonition.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/markdown/extensions/admonition.py b/markdown/extensions/admonition.py
index 916d931..9c66b4f 100644
--- a/markdown/extensions/admonition.py
+++ b/markdown/extensions/admonition.py
@@ -48,7 +48,7 @@ class AdmonitionProcessor(BlockProcessor):
self.current_sibling = None
self.content_indention = 0
- def get_sibling(self, parent, block):
+ def parse_content(self, parent, block):
"""Get sibling admontion.
Retrieve the appropriate siblimg element. This can get trickly when
@@ -56,13 +56,16 @@ class AdmonitionProcessor(BlockProcessor):
"""
+ old_block = block
+ the_rest = ''
+
# We already acquired the block via test
if self.current_sibling is not None:
sibling = self.current_sibling
- block = block[self.content_indent:]
+ block, the_rest = self.detab(block, self.content_indent)
self.current_sibling = None
self.content_indent = 0
- return sibling, block
+ return sibling, block, the_rest
sibling = self.lastChild(parent)
@@ -96,17 +99,19 @@ class AdmonitionProcessor(BlockProcessor):
sibling = None
if sibling is not None:
+ indent += self.tab_length
+ block, the_rest = self.detab(old_block, indent)
self.current_sibling = sibling
self.content_indent = indent
- return sibling, block
+ return sibling, block, the_rest
def test(self, parent, block):
if self.RE.search(block):
return True
else:
- return self.get_sibling(parent, block)[0] is not None
+ return self.parse_content(parent, block)[0] is not None
def run(self, parent, blocks):
block = blocks.pop(0)
@@ -116,10 +121,9 @@ class AdmonitionProcessor(BlockProcessor):
if m.start() > 0:
self.parser.parseBlocks(parent, [block[:m.start()]])
block = block[m.end():] # removes the first line
+ block, theRest = self.detab(block)
else:
- sibling, block = self.get_sibling(parent, block)
-
- block, theRest = self.detab(block)
+ sibling, block, theRest = self.parse_content(parent, block)
if m:
klass, title = self.get_class_and_title(m)