20 """Convert blockquotes into admonitions if they start with a marker.
21
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.
25 """
26 processed = []
27 current_admonition = None
28 indent = ''
29 for line in content.split('\n'):
30 if current_admonition is not None:
31 if line.startswith('>'):
32 processed.append(indent + line[1:])
33 continue
34 if current_admonition == 'Note':
35 note = processed.pop()
36 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':
43 indent = ''
44
45
46 while processed[-1] == '':
47 processed.pop()
48
49
50 if processed[-1].startswith('#'):
51 processed.append('')
52 else:
53
54 processed.append(
55 f'!!! {_RECOGNIZED_ADMONITIONS[current_admonition]} "{current_admonition}"'
56 )
57 current_admonition = True
58 indent = ' '
59 continue
60 processed.append(line)
61 return "\n".
join(processed)
str convert_admonitions(str content)
static SkString join(const CommandLineFlags::StringArray &)