support title-only callouts correctly and add more styles for content

This commit is contained in:
Amy G. Bowersox 2024-08-11 00:41:07 -06:00
parent 743896b4b2
commit 1a92e7aa97
2 changed files with 17 additions and 11 deletions

View File

@ -892,17 +892,18 @@ class ObsidianStyleBlockquotes(Extension):
# TODO: add title icon here
inner_title_div = etree.SubElement(title_div, 'div', {'class': 'callout-title-inner'})
inner_title_div.text = title
content_div = etree.SubElement(base_div, 'div', {'class': 'callout-content'})
lines.pop(0)
first = True
for line in lines:
if first:
first = False
else:
etree.SubElement(content_div, 'br')
self.parser.state.set('list')
self.parser.parseBlocks(content_div, [line])
self.parser.state.reset()
if len(lines) > 0:
content_div = etree.SubElement(base_div, 'div', {'class': 'callout-content'})
first = True
for line in lines:
if first:
first = False
else:
etree.SubElement(content_div, 'br')
self.parser.state.set('list')
self.parser.parseBlocks(content_div, [line])
self.parser.state.reset()
def run(self, parent: etree.Element, blocks: list[str]) -> None:
block = blocks.pop(0)

View File

@ -80,12 +80,17 @@ th {
color: rgb(var(--callout-color));
line-height: 1.3;
align-items: flex-start;
margin-bottom: 1em;
}
.callout-title-inner {
font-weight: 600;
color: inherit;
}
.callout-content {
margin-top: 1em;
overflow-x: auto;
padding: 0;
background-color: transparent;
}
/* Following are styles generated by Pygments "tango" style */
pre { line-height: 125%; }