Fix blockquote issues

This commit is contained in:
august kline 2025-01-06 16:47:50 -05:00
parent 725a77318a
commit d6f16fe65e
2 changed files with 25 additions and 17 deletions

View File

@ -71,10 +71,12 @@ input,
label, label,
a, a,
blockquote, blockquote,
figcaption,
aside, aside,
ol, ol,
ul { ul {
font-size: calc(var(--font-size) * 1.33); font-size: calc(var(--font-size) * 1.33);
line-height: 1.5em;
} }
h1, h1,
@ -87,26 +89,22 @@ h6 {
} }
aside, aside,
blockquote { figure {
border: var(--border);
}
blockquote,
aside {
padding: var(--default-padding) calc(var(--default-padding) * 2); padding: var(--default-padding) calc(var(--default-padding) * 2);
border: var(--border);
max-inline-size: 100%; max-inline-size: 100%;
margin-inline: 0; margin-inline: 0;
} }
blockquote { blockquote {
&::before { margin: 0;
content: '“';
font-weight: 600;
} }
&::after { figure {
content: '”'; & figcaption {
font-weight: 600; font-style: italic;
margin-inline-start: var(--default-padding);
margin-block-start: var(--default-padding);
} }
} }

View File

@ -34,6 +34,7 @@ pub(crate) enum Block {
}, },
quote { quote {
text: String, text: String,
caption: String,
}, },
embed { embed {
service: String, service: String,
@ -78,7 +79,13 @@ impl Block {
} }
}, },
Block::warning { title } => ["<aside>", title, "</aside>"].concat(), Block::warning { title } => ["<aside>", title, "</aside>"].concat(),
Block::quote { text } => ["<blockquote>", text, "</blockquote>"].concat(), Block::quote { text, caption } => {
if caption.is_empty() {
["<figure><blockquote>“", text, "”</blockquote></figure>"].concat()
} else {
["<figure><blockquote>“", text, "”</blockquote><figcaption>— ", caption,"</figcaption></figure>"].concat()
}
},
Block::embed { Block::embed {
embed, embed,
width, width,
@ -109,7 +116,7 @@ impl Block {
Block::header { text, level: _ } => text, Block::header { text, level: _ } => text,
Block::list { style: _, items } => &items.join("\n"), Block::list { style: _, items } => &items.join("\n"),
Block::warning { title } => title, Block::warning { title } => title,
Block::quote { text } => text, Block::quote { text, caption } => &[text, caption.as_str()].concat(),
_ => &"".to_string(), _ => &"".to_string(),
}; };
let text = [text, "\n"].concat(); let text = [text, "\n"].concat();
@ -241,14 +248,17 @@ impl Blocks {
Block::paragraph { text: _ } => true, Block::paragraph { text: _ } => true,
Block::header { text: _, level } => *level > 1, Block::header { text: _, level } => *level > 1,
Block::warning { title: _ } => true, Block::warning { title: _ } => true,
Block::quote { text: _ } => true, Block::quote {
text: _,
caption: _,
} => true,
_ => false, _ => false,
}) })
.map(|block| match block { .map(|block| match block {
Block::paragraph { text } => text, Block::paragraph { text } => text,
Block::header { text, level: _ } => text, Block::header { text, level: _ } => text,
Block::warning { title } => title, Block::warning { title } => title,
Block::quote { text } => text, Block::quote { text, caption: _ } => text,
_ => "...", _ => "...",
}) })
.unwrap_or("No description"), .unwrap_or("No description"),