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

View File

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