Quote body is not a paragraph

This commit is contained in:
Laurenz 2025-01-23 17:54:08 +01:00
parent e40bf22c23
commit 2492ba42ed
5 changed files with 27 additions and 9 deletions

View File

@ -212,17 +212,24 @@ impl Show for Packed<QuoteElem> {
.pack() .pack()
.spanned(self.span()), .spanned(self.span()),
}; };
let attribution = let attribution = Content::sequence([
[TextElem::packed('—'), SpaceElem::shared().clone(), attribution]; TextElem::packed('—'),
SpaceElem::shared().clone(),
attribution,
]);
if !html { if html {
// Use v(0.9em, weak: true) to bring the attribution closer realized += attribution;
// to the quote. } else {
// Bring the attribution a bit closer to the quote.
let gap = Spacing::Rel(Em::new(0.9).into()); let gap = Spacing::Rel(Em::new(0.9).into());
let v = VElem::new(gap).with_weak(true).pack(); let v = VElem::new(gap).with_weak(true).pack();
realized += v; realized += v;
realized += BlockElem::new()
.with_body(Some(BlockBody::Content(attribution)))
.pack()
.aligned(Alignment::END);
} }
realized += Content::sequence(attribution).aligned(Alignment::END);
} }
if !html { if !html {

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
<body> <body>
<blockquote cite="https://typst.app/home"> Compose papers faster </blockquote> <blockquote cite="https://typst.app/home">Compose papers faster</blockquote>
<p><a href="https://typst.app/home">typst.com</a></p> <p><a href="https://typst.app/home">typst.com</a></p>
</body> </body>
</html> </html>

View File

@ -5,9 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
<body> <body>
<blockquote> … ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι. </blockquote> <blockquote>… ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι.</blockquote>
<p>— Plato</p> <p>— Plato</p>
<blockquote> … I seem, then, in just this little thing to be wiser than this man at any rate, that what I do not know I do not think I know either. </blockquote> <blockquote>… I seem, then, in just this little thing to be wiser than this man at any rate, that what I do not know I do not think I know either.</blockquote>
<p>— from the Henry Cary literal translation of 1897</p> <p>— from the Henry Cary literal translation of 1897</p>
</body> </body>
</html> </html>

BIN
tests/ref/quote-par.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -107,3 +107,14 @@ When you said that #quote[he surely meant that #quote[she intended to say #quote
)[ )[
Compose papers faster Compose papers faster
] ]
--- quote-par ---
// Ensure that an inline quote is part of a paragraph, but a block quote
// does not result in paragraphs.
#show par: highlight
An inline #quote[quote.]
#quote(block: true, attribution: [The Test Author])[
A block-level quote.
]