5"""Preprocesses Markdown source and converts admonitions written in blockquotes.
7Usage: convert_admonitions(str)
12_RECOGNIZED_ADMONITIONS = {
13 "Source to read":
"sourcecode",
20 """Convert blockquotes into admonitions if they start with a marker.
22 Blockquotes starting with `> **marker**` are converted either into
23 sidenotes (`<span
class=
"aside"/>`)
or into admonitions to be
24 processed by an admonition extension later.
27 current_admonition = None
29 for line
in content.split(
'\n'):
30 if current_admonition
is not None:
31 if line.startswith(
'>'):
32 processed.append(indent + line[1:])
34 if current_admonition ==
'Note':
35 note = processed.pop()
37 processed[-1] = processed[
38 -1] + f
' <span class="aside" markdown=1>{note}</span>'
39 current_admonition =
None
40 elif line.startswith(
'> **')
and line.endswith(
'**'):
41 current_admonition = re.match(
r'^> \*\*(.*)\*\*$', line)[1]
42 if current_admonition ==
'Note':
46 while processed[-1] ==
'':
50 if processed[-1].startswith(
'#'):
55 f
'!!! {_RECOGNIZED_ADMONITIONS[current_admonition]} "{current_admonition}"'
57 current_admonition =
True
60 processed.append(line)
61 return "\n".
join(processed)
str convert_admonitions(str content)
static SkString join(const CommandLineFlags::StringArray &)