From 1a92e7aa970f718da614d9f8036037e12cff4e56 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 11 Aug 2024 00:41:07 -0600 Subject: [PATCH] support title-only callouts correctly and add more styles for content --- src/dragonglass/mparse.py | 21 +++++++++++---------- src/dragonglass/style.py | 7 ++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/dragonglass/mparse.py b/src/dragonglass/mparse.py index 37c2929..22219f9 100644 --- a/src/dragonglass/mparse.py +++ b/src/dragonglass/mparse.py @@ -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) diff --git a/src/dragonglass/style.py b/src/dragonglass/style.py index 3ad9704..aac5a31 100644 --- a/src/dragonglass/style.py +++ b/src/dragonglass/style.py @@ -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%; }