Compare commits
3 Commits
69c3f95705
...
36d83c8c09
Author | SHA1 | Date | |
---|---|---|---|
|
36d83c8c09 | ||
|
3744c99b07 | ||
|
81efc82d3c |
@ -307,18 +307,18 @@ fn head_element(info: &DocumentInfo) -> HtmlElement {
|
|||||||
|
|
||||||
/// Determine which kind of output the user generated.
|
/// Determine which kind of output the user generated.
|
||||||
fn classify_output(mut output: Vec<HtmlNode>) -> SourceResult<OutputKind> {
|
fn classify_output(mut output: Vec<HtmlNode>) -> SourceResult<OutputKind> {
|
||||||
let len = output.len();
|
let count = output.iter().filter(|node| !matches!(node, HtmlNode::Tag(_))).count();
|
||||||
for node in &mut output {
|
for node in &mut output {
|
||||||
let HtmlNode::Element(elem) = node else { continue };
|
let HtmlNode::Element(elem) = node else { continue };
|
||||||
let tag = elem.tag;
|
let tag = elem.tag;
|
||||||
let mut take = || std::mem::replace(elem, HtmlElement::new(tag::html));
|
let mut take = || std::mem::replace(elem, HtmlElement::new(tag::html));
|
||||||
match (tag, len) {
|
match (tag, count) {
|
||||||
(tag::html, 1) => return Ok(OutputKind::Html(take())),
|
(tag::html, 1) => return Ok(OutputKind::Html(take())),
|
||||||
(tag::body, 1) => return Ok(OutputKind::Body(take())),
|
(tag::body, 1) => return Ok(OutputKind::Body(take())),
|
||||||
(tag::html | tag::body, _) => bail!(
|
(tag::html | tag::body, _) => bail!(
|
||||||
elem.span,
|
elem.span,
|
||||||
"`{}` element must be the only element in the document",
|
"`{}` element must be the only element in the document",
|
||||||
elem.tag
|
elem.tag,
|
||||||
),
|
),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ pub fn layout_accent(
|
|||||||
|
|
||||||
// Try to replace accent glyph with flattened variant.
|
// Try to replace accent glyph with flattened variant.
|
||||||
let flattened_base_height = scaled!(ctx, styles, flattened_accent_base_height);
|
let flattened_base_height = scaled!(ctx, styles, flattened_accent_base_height);
|
||||||
if base.height() > flattened_base_height {
|
if base.ascent() > flattened_base_height {
|
||||||
glyph.make_flattened_accent_form(ctx);
|
glyph.make_flattened_accent_form(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ pub fn layout_accent(
|
|||||||
// minus the accent base height. Only if the base is very small, we need
|
// minus the accent base height. Only if the base is very small, we need
|
||||||
// a larger gap so that the accent doesn't move too low.
|
// a larger gap so that the accent doesn't move too low.
|
||||||
let accent_base_height = scaled!(ctx, styles, accent_base_height);
|
let accent_base_height = scaled!(ctx, styles, accent_base_height);
|
||||||
let gap = -accent.descent() - base.height().min(accent_base_height);
|
let gap = -accent.descent() - base.ascent().min(accent_base_height);
|
||||||
let size = Size::new(base.width(), accent.height() + gap + base.height());
|
let size = Size::new(base.width(), accent.height() + gap + base.height());
|
||||||
let accent_pos = Point::with_x(base_attach - accent_attach);
|
let accent_pos = Point::with_x(base_attach - accent_attach);
|
||||||
let base_pos = Point::with_y(accent.height() + gap);
|
let base_pos = Point::with_y(accent.height() + gap);
|
||||||
|
@ -360,6 +360,21 @@ pub fn default_math_class(c: char) -> Option<MathClass> {
|
|||||||
// https://github.com/typst/typst/pull/5714
|
// https://github.com/typst/typst/pull/5714
|
||||||
'\u{22A5}' => Some(MathClass::Normal),
|
'\u{22A5}' => Some(MathClass::Normal),
|
||||||
|
|
||||||
|
// Used as a binary connector in linear logic, where it is referred to
|
||||||
|
// as "par".
|
||||||
|
// https://github.com/typst/typst/issues/5764
|
||||||
|
'⅋' => Some(MathClass::Binary),
|
||||||
|
|
||||||
|
// Those overrides should become the default in the next revision of
|
||||||
|
// MathClass.txt.
|
||||||
|
// https://github.com/typst/typst/issues/5764#issuecomment-2632435247
|
||||||
|
'⎰' | '⟅' => Some(MathClass::Opening),
|
||||||
|
'⎱' | '⟆' => Some(MathClass::Closing),
|
||||||
|
|
||||||
|
// Both ∨ and ⟑ are classified as Binary.
|
||||||
|
// https://github.com/typst/typst/issues/5764
|
||||||
|
'⟇' => Some(MathClass::Binary),
|
||||||
|
|
||||||
c => unicode_math_class::class(c),
|
c => unicode_math_class::class(c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
2
tests/ref/html/html-elem-alone-context.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html></html>
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 625 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 327 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 930 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
7
tests/suite/html/elem.typ
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
--- html-elem-alone-context html ---
|
||||||
|
#context html.elem("html")
|
||||||
|
|
||||||
|
--- html-elem-not-alone html ---
|
||||||
|
// Error: 2-19 `<html>` element must be the only element in the document
|
||||||
|
#html.elem("html")
|
||||||
|
Text
|