Skip to content

Commit

Permalink
Update regex to allow leading whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sondregronas committed Jun 27, 2022
1 parent 0a42a39 commit eaad99e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mkdocs_callouts/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def on_page_markdown(self, markdown, page, config, files):
for line in markdown.split('\n'):
# Find callout box denotation(s) and parse the
# title/type (regex covers nested callouts)
if re.search(r'^( ?>*)*\[!(.*)\]', line):
if re.search(r'^ ?>* *\[![^\]]*\]', line):
is_callout = True
line = parse_callout_block(line)

# Parse the callout content, replacing > symbols with indentation
elif line.startswith('>') and is_callout:
indent = re.findall('^>+', line)
indent = '\t' * len(indent[0])
line = re.sub('^>+ ?', indent, line)
elif re.search(r'^ ?>+', line) and is_callout:
indent = re.search('^ ?(>+)', line)
indent = '\t' * indent.group(1).count('>')
line = re.sub('^ ?>+ ?', indent, line)

# End callout block when no leading > is present
elif is_callout:
Expand Down

0 comments on commit eaad99e

Please sign in to comment.