mirror of
https://github.com/typst/typst
synced 2025-07-27 06:17:53 +08:00
feat: add alt
parameter to math.equation
This commit is contained in:
parent
d2105dcc35
commit
9649def108
@ -1,6 +1,7 @@
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
use codex::styling::MathVariant;
|
||||
use ecow::EcoString;
|
||||
use typst_utils::NonZeroExt;
|
||||
use unicode_math_class::MathClass;
|
||||
|
||||
@ -47,6 +48,9 @@ use crate::text::{FontFamily, FontList, FontWeight, LocalName, TextElem};
|
||||
/// [main math page]($category/math).
|
||||
#[elem(Locatable, Synthesize, ShowSet, Count, LocalName, Refable, Outlinable)]
|
||||
pub struct EquationElem {
|
||||
/// An alternative description of the mathematical equation.
|
||||
pub alt: Option<EcoString>,
|
||||
|
||||
/// Whether the equation is displayed as a separate block.
|
||||
#[default(false)]
|
||||
pub block: bool,
|
||||
|
@ -88,7 +88,7 @@ use crate::text::{LocalName, TextElem};
|
||||
/// generated.
|
||||
#[elem(Locatable)]
|
||||
pub struct LinkElem {
|
||||
/// A text describing the link.
|
||||
/// An alternative description of the link.
|
||||
pub alt: Option<EcoString>,
|
||||
|
||||
/// The destination the link points to.
|
||||
|
@ -124,7 +124,7 @@ pub struct ImageElem {
|
||||
/// The height of the image.
|
||||
pub height: Sizing,
|
||||
|
||||
/// A text describing the image.
|
||||
/// An alternative description of the image.
|
||||
pub alt: Option<EcoString>,
|
||||
|
||||
/// How the image should adjust itself to a given area (the area is defined
|
||||
|
@ -123,9 +123,9 @@ pub(crate) fn handle_start(
|
||||
} else {
|
||||
TagKind::Figure.with_alt_text(alt)
|
||||
}
|
||||
} else if let Some(_) = elem.to_packed::<EquationElem>() {
|
||||
// TODO: alt text
|
||||
TagKind::Formula.into()
|
||||
} else if let Some(equation) = elem.to_packed::<EquationElem>() {
|
||||
let alt = equation.alt.get_as_ref().map(|s| s.to_string());
|
||||
TagKind::Formula.with_alt_text(alt)
|
||||
} else if let Some(table) = elem.to_packed::<TableElem>() {
|
||||
let table_id = gc.tags.next_table_id();
|
||||
let summary = table.summary.get_as_ref().map(|s| s.to_string());
|
||||
|
Loading…
x
Reference in New Issue
Block a user