Compare commits
No commits in common. "012e14d40cb44997630cf6469a446f217f2e9057" and "e60d3021a782c5977cf7de726682e19ae89abeb3" have entirely different histories.
012e14d40c
...
e60d3021a7
@ -19,10 +19,8 @@ pub fn layout_accent(
|
|||||||
let mut base = ctx.layout_into_fragment(&elem.base, styles.chain(&cramped))?;
|
let mut base = ctx.layout_into_fragment(&elem.base, styles.chain(&cramped))?;
|
||||||
|
|
||||||
// Try to replace a glyph with its dotless variant.
|
// Try to replace a glyph with its dotless variant.
|
||||||
if elem.dotless(styles) {
|
if let MathFragment::Glyph(glyph) = &mut base {
|
||||||
if let MathFragment::Glyph(glyph) = &mut base {
|
glyph.make_dotless_form(ctx);
|
||||||
glyph.make_dotless_form(ctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preserve class to preserve automatic spacing.
|
// Preserve class to preserve automatic spacing.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use typst_library::diag::{bail, warning, SourceResult};
|
use typst_library::diag::{bail, SourceResult};
|
||||||
use typst_library::foundations::{Content, Packed, Resolve, StyleChain};
|
use typst_library::foundations::{Content, Packed, Resolve, StyleChain};
|
||||||
use typst_library::layout::{
|
use typst_library::layout::{
|
||||||
Abs, Axes, Em, FixedAlignment, Frame, FrameItem, Point, Ratio, Rel, Size,
|
Abs, Axes, Em, FixedAlignment, Frame, FrameItem, Point, Ratio, Rel, Size,
|
||||||
@ -9,7 +9,7 @@ use typst_library::visualize::{FillRule, FixedStroke, Geometry, LineCap, Shape};
|
|||||||
use typst_syntax::Span;
|
use typst_syntax::Span;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
alignments, delimiter_alignment, style_for_denominator, AlignmentResult,
|
alignments, delimiter_alignment, stack, style_for_denominator, AlignmentResult,
|
||||||
FrameFragment, GlyphFragment, LeftRightAlternator, MathContext, DELIM_SHORT_FALL,
|
FrameFragment, GlyphFragment, LeftRightAlternator, MathContext, DELIM_SHORT_FALL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -23,51 +23,17 @@ pub fn layout_vec(
|
|||||||
ctx: &mut MathContext,
|
ctx: &mut MathContext,
|
||||||
styles: StyleChain,
|
styles: StyleChain,
|
||||||
) -> SourceResult<()> {
|
) -> SourceResult<()> {
|
||||||
let span = elem.span();
|
let delim = elem.delim(styles);
|
||||||
|
let frame = layout_vec_body(
|
||||||
let column: Vec<&Content> = elem.children.iter().collect();
|
|
||||||
let frame = layout_body(
|
|
||||||
ctx,
|
ctx,
|
||||||
styles,
|
styles,
|
||||||
&[column],
|
&elem.children,
|
||||||
elem.align(styles),
|
elem.align(styles),
|
||||||
|
elem.gap(styles),
|
||||||
LeftRightAlternator::Right,
|
LeftRightAlternator::Right,
|
||||||
None,
|
|
||||||
Axes::with_y(elem.gap(styles)),
|
|
||||||
span,
|
|
||||||
"elements",
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let delim = elem.delim(styles);
|
layout_delimiters(ctx, styles, frame, delim.open(), delim.close(), elem.span())
|
||||||
layout_delimiters(ctx, styles, frame, delim.open(), delim.close(), span)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Lays out a [`CasesElem`].
|
|
||||||
#[typst_macros::time(name = "math.cases", span = elem.span())]
|
|
||||||
pub fn layout_cases(
|
|
||||||
elem: &Packed<CasesElem>,
|
|
||||||
ctx: &mut MathContext,
|
|
||||||
styles: StyleChain,
|
|
||||||
) -> SourceResult<()> {
|
|
||||||
let span = elem.span();
|
|
||||||
|
|
||||||
let column: Vec<&Content> = elem.children.iter().collect();
|
|
||||||
let frame = layout_body(
|
|
||||||
ctx,
|
|
||||||
styles,
|
|
||||||
&[column],
|
|
||||||
FixedAlignment::Start,
|
|
||||||
LeftRightAlternator::None,
|
|
||||||
None,
|
|
||||||
Axes::with_y(elem.gap(styles)),
|
|
||||||
span,
|
|
||||||
"branches",
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let delim = elem.delim(styles);
|
|
||||||
let (open, close) =
|
|
||||||
if elem.reverse(styles) { (None, delim.close()) } else { (delim.open(), None) };
|
|
||||||
layout_delimiters(ctx, styles, frame, open, close, span)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lays out a [`MatElem`].
|
/// Lays out a [`MatElem`].
|
||||||
@ -77,16 +43,14 @@ pub fn layout_mat(
|
|||||||
ctx: &mut MathContext,
|
ctx: &mut MathContext,
|
||||||
styles: StyleChain,
|
styles: StyleChain,
|
||||||
) -> SourceResult<()> {
|
) -> SourceResult<()> {
|
||||||
let span = elem.span();
|
|
||||||
let rows = &elem.rows;
|
|
||||||
let ncols = rows.first().map_or(0, |row| row.len());
|
|
||||||
|
|
||||||
let augment = elem.augment(styles);
|
let augment = elem.augment(styles);
|
||||||
|
let rows = &elem.rows;
|
||||||
|
|
||||||
if let Some(aug) = &augment {
|
if let Some(aug) = &augment {
|
||||||
for &offset in &aug.hline.0 {
|
for &offset in &aug.hline.0 {
|
||||||
if offset == 0 || offset.unsigned_abs() >= rows.len() {
|
if offset == 0 || offset.unsigned_abs() >= rows.len() {
|
||||||
bail!(
|
bail!(
|
||||||
span,
|
elem.span(),
|
||||||
"cannot draw a horizontal line after row {} of a matrix with {} rows",
|
"cannot draw a horizontal line after row {} of a matrix with {} rows",
|
||||||
if offset < 0 { rows.len() as isize + offset } else { offset },
|
if offset < 0 { rows.len() as isize + offset } else { offset },
|
||||||
rows.len()
|
rows.len()
|
||||||
@ -94,55 +58,95 @@ pub fn layout_mat(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ncols = rows.first().map_or(0, |row| row.len());
|
||||||
|
|
||||||
for &offset in &aug.vline.0 {
|
for &offset in &aug.vline.0 {
|
||||||
if offset == 0 || offset.unsigned_abs() >= ncols {
|
if offset == 0 || offset.unsigned_abs() >= ncols {
|
||||||
bail!(
|
bail!(
|
||||||
span,
|
elem.span(),
|
||||||
"cannot draw a vertical line after column {} of a matrix with {} columns",
|
"cannot draw a vertical line after column {} of a matrix with {} columns",
|
||||||
if offset < 0 { ncols as isize + offset } else { offset },
|
if offset < 0 { ncols as isize + offset } else { offset },
|
||||||
ncols
|
ncols
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transpose rows of the matrix into columns.
|
let delim = elem.delim(styles);
|
||||||
let mut row_iters: Vec<_> = rows.iter().map(|i| i.iter()).collect();
|
let frame = layout_mat_body(
|
||||||
let columns: Vec<Vec<_>> = (0..ncols)
|
|
||||||
.map(|_| row_iters.iter_mut().map(|i| i.next().unwrap()).collect())
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let frame = layout_body(
|
|
||||||
ctx,
|
ctx,
|
||||||
styles,
|
styles,
|
||||||
&columns,
|
rows,
|
||||||
elem.align(styles),
|
elem.align(styles),
|
||||||
LeftRightAlternator::Right,
|
|
||||||
augment,
|
augment,
|
||||||
Axes::new(elem.column_gap(styles), elem.row_gap(styles)),
|
Axes::new(elem.column_gap(styles), elem.row_gap(styles)),
|
||||||
span,
|
elem.span(),
|
||||||
"cells",
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let delim = elem.delim(styles);
|
layout_delimiters(ctx, styles, frame, delim.open(), delim.close(), elem.span())
|
||||||
layout_delimiters(ctx, styles, frame, delim.open(), delim.close(), span)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Layout the inner contents of a matrix, vector, or cases.
|
/// Lays out a [`CasesElem`].
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[typst_macros::time(name = "math.cases", span = elem.span())]
|
||||||
fn layout_body(
|
pub fn layout_cases(
|
||||||
|
elem: &Packed<CasesElem>,
|
||||||
ctx: &mut MathContext,
|
ctx: &mut MathContext,
|
||||||
styles: StyleChain,
|
styles: StyleChain,
|
||||||
columns: &[Vec<&Content>],
|
) -> SourceResult<()> {
|
||||||
|
let delim = elem.delim(styles);
|
||||||
|
let frame = layout_vec_body(
|
||||||
|
ctx,
|
||||||
|
styles,
|
||||||
|
&elem.children,
|
||||||
|
FixedAlignment::Start,
|
||||||
|
elem.gap(styles),
|
||||||
|
LeftRightAlternator::None,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let (open, close) =
|
||||||
|
if elem.reverse(styles) { (None, delim.close()) } else { (delim.open(), None) };
|
||||||
|
|
||||||
|
layout_delimiters(ctx, styles, frame, open, close, elem.span())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Layout the inner contents of a vector.
|
||||||
|
fn layout_vec_body(
|
||||||
|
ctx: &mut MathContext,
|
||||||
|
styles: StyleChain,
|
||||||
|
column: &[Content],
|
||||||
align: FixedAlignment,
|
align: FixedAlignment,
|
||||||
|
row_gap: Rel<Abs>,
|
||||||
alternator: LeftRightAlternator,
|
alternator: LeftRightAlternator,
|
||||||
|
) -> SourceResult<Frame> {
|
||||||
|
let gap = row_gap.relative_to(ctx.region.size.y);
|
||||||
|
|
||||||
|
let denom_style = style_for_denominator(styles);
|
||||||
|
let mut flat = vec![];
|
||||||
|
for child in column {
|
||||||
|
// We allow linebreaks in cases and vectors, which are functionally
|
||||||
|
// identical to commas.
|
||||||
|
flat.extend(ctx.layout_into_run(child, styles.chain(&denom_style))?.rows());
|
||||||
|
}
|
||||||
|
// We pad ascent and descent with the ascent and descent of the paren
|
||||||
|
// to ensure that normal vectors are aligned with others unless they are
|
||||||
|
// way too big.
|
||||||
|
let paren =
|
||||||
|
GlyphFragment::new(ctx, styles.chain(&denom_style), '(', Span::detached());
|
||||||
|
Ok(stack(flat, align, gap, 0, alternator, Some((paren.ascent, paren.descent))))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Layout the inner contents of a matrix.
|
||||||
|
fn layout_mat_body(
|
||||||
|
ctx: &mut MathContext,
|
||||||
|
styles: StyleChain,
|
||||||
|
rows: &[Vec<Content>],
|
||||||
|
align: FixedAlignment,
|
||||||
augment: Option<Augment<Abs>>,
|
augment: Option<Augment<Abs>>,
|
||||||
gap: Axes<Rel<Abs>>,
|
gap: Axes<Rel<Abs>>,
|
||||||
span: Span,
|
span: Span,
|
||||||
children: &str,
|
|
||||||
) -> SourceResult<Frame> {
|
) -> SourceResult<Frame> {
|
||||||
let nrows = columns.first().map_or(0, |col| col.len());
|
let ncols = rows.first().map_or(0, |row| row.len());
|
||||||
let ncols = columns.len();
|
let nrows = rows.len();
|
||||||
if ncols == 0 || nrows == 0 {
|
if ncols == 0 || nrows == 0 {
|
||||||
return Ok(Frame::soft(Size::zero()));
|
return Ok(Frame::soft(Size::zero()));
|
||||||
}
|
}
|
||||||
@ -174,11 +178,16 @@ fn layout_body(
|
|||||||
// Before the full matrix body can be laid out, the
|
// Before the full matrix body can be laid out, the
|
||||||
// individual cells must first be independently laid out
|
// individual cells must first be independently laid out
|
||||||
// so we can ensure alignment across rows and columns.
|
// so we can ensure alignment across rows and columns.
|
||||||
let mut cols = vec![vec![]; ncols];
|
|
||||||
|
|
||||||
// This variable stores the maximum ascent and descent for each row.
|
// This variable stores the maximum ascent and descent for each row.
|
||||||
let mut heights = vec![(Abs::zero(), Abs::zero()); nrows];
|
let mut heights = vec![(Abs::zero(), Abs::zero()); nrows];
|
||||||
|
|
||||||
|
// We want to transpose our data layout to columns
|
||||||
|
// before final layout. For efficiency, the columns
|
||||||
|
// variable is set up here and newly generated
|
||||||
|
// individual cells are then added to it.
|
||||||
|
let mut cols = vec![vec![]; ncols];
|
||||||
|
|
||||||
let denom_style = style_for_denominator(styles);
|
let denom_style = style_for_denominator(styles);
|
||||||
// We pad ascent and descent with the ascent and descent of the paren
|
// We pad ascent and descent with the ascent and descent of the paren
|
||||||
// to ensure that normal matrices are aligned with others unless they are
|
// to ensure that normal matrices are aligned with others unless they are
|
||||||
@ -186,22 +195,10 @@ fn layout_body(
|
|||||||
let paren =
|
let paren =
|
||||||
GlyphFragment::new(ctx, styles.chain(&denom_style), '(', Span::detached());
|
GlyphFragment::new(ctx, styles.chain(&denom_style), '(', Span::detached());
|
||||||
|
|
||||||
for (column, col) in columns.iter().zip(&mut cols) {
|
for (row, (ascent, descent)) in rows.iter().zip(&mut heights) {
|
||||||
for (cell, (ascent, descent)) in column.iter().zip(&mut heights) {
|
for (cell, col) in row.iter().zip(&mut cols) {
|
||||||
let cell_span = cell.span();
|
|
||||||
let cell = ctx.layout_into_run(cell, styles.chain(&denom_style))?;
|
let cell = ctx.layout_into_run(cell, styles.chain(&denom_style))?;
|
||||||
|
|
||||||
// We ignore linebreaks in the cells as we can't differentiate
|
|
||||||
// alignment points for the whole body from ones for a specific
|
|
||||||
// cell, and multiline cells don't quite make sense at the moment.
|
|
||||||
if cell.is_multiline() {
|
|
||||||
ctx.engine.sink.warn(warning!(
|
|
||||||
cell_span,
|
|
||||||
"linebreaks are ignored in {}", children;
|
|
||||||
hint: "use commas instead to separate each line"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
ascent.set_max(cell.ascent().max(paren.ascent));
|
ascent.set_max(cell.ascent().max(paren.ascent));
|
||||||
descent.set_max(cell.descent().max(paren.descent));
|
descent.set_max(cell.descent().max(paren.descent));
|
||||||
|
|
||||||
@ -225,7 +222,7 @@ fn layout_body(
|
|||||||
let mut y = Abs::zero();
|
let mut y = Abs::zero();
|
||||||
|
|
||||||
for (cell, &(ascent, descent)) in col.into_iter().zip(&heights) {
|
for (cell, &(ascent, descent)) in col.into_iter().zip(&heights) {
|
||||||
let cell = cell.into_line_frame(&points, alternator);
|
let cell = cell.into_line_frame(&points, LeftRightAlternator::Right);
|
||||||
let pos = Point::new(
|
let pos = Point::new(
|
||||||
if points.is_empty() {
|
if points.is_empty() {
|
||||||
x + align.position(rcol - cell.width())
|
x + align.position(rcol - cell.width())
|
||||||
|
@ -117,6 +117,7 @@ pub fn stack(
|
|||||||
gap: Abs,
|
gap: Abs,
|
||||||
baseline: usize,
|
baseline: usize,
|
||||||
alternator: LeftRightAlternator,
|
alternator: LeftRightAlternator,
|
||||||
|
minimum_ascent_descent: Option<(Abs, Abs)>,
|
||||||
) -> Frame {
|
) -> Frame {
|
||||||
let AlignmentResult { points, width } = alignments(&rows);
|
let AlignmentResult { points, width } = alignments(&rows);
|
||||||
let rows: Vec<_> = rows
|
let rows: Vec<_> = rows
|
||||||
@ -124,9 +125,13 @@ pub fn stack(
|
|||||||
.map(|row| row.into_line_frame(&points, alternator))
|
.map(|row| row.into_line_frame(&points, alternator))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let padded_height = |height: Abs| {
|
||||||
|
height.max(minimum_ascent_descent.map_or(Abs::zero(), |(a, d)| a + d))
|
||||||
|
};
|
||||||
|
|
||||||
let mut frame = Frame::soft(Size::new(
|
let mut frame = Frame::soft(Size::new(
|
||||||
width,
|
width,
|
||||||
rows.iter().map(|row| row.height()).sum::<Abs>()
|
rows.iter().map(|row| padded_height(row.height())).sum::<Abs>()
|
||||||
+ rows.len().saturating_sub(1) as f64 * gap,
|
+ rows.len().saturating_sub(1) as f64 * gap,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -137,11 +142,14 @@ pub fn stack(
|
|||||||
} else {
|
} else {
|
||||||
Abs::zero()
|
Abs::zero()
|
||||||
};
|
};
|
||||||
let pos = Point::new(x, y);
|
let ascent_padded_part = minimum_ascent_descent
|
||||||
|
.map_or(Abs::zero(), |(a, _)| (a - row.ascent()))
|
||||||
|
.max(Abs::zero());
|
||||||
|
let pos = Point::new(x, y + ascent_padded_part);
|
||||||
if i == baseline {
|
if i == baseline {
|
||||||
frame.set_baseline(y + row.baseline());
|
frame.set_baseline(y + row.baseline() + ascent_padded_part);
|
||||||
}
|
}
|
||||||
y += row.height() + gap;
|
y += padded_height(row.height()) + gap;
|
||||||
frame.push_frame(pos, row);
|
frame.push_frame(pos, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,8 +312,14 @@ fn layout_underoverspreader(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let frame =
|
let frame = stack(
|
||||||
stack(rows, FixedAlignment::Center, gap, baseline, LeftRightAlternator::Right);
|
rows,
|
||||||
|
FixedAlignment::Center,
|
||||||
|
gap,
|
||||||
|
baseline,
|
||||||
|
LeftRightAlternator::Right,
|
||||||
|
None,
|
||||||
|
);
|
||||||
ctx.push(FrameFragment::new(styles, frame).with_class(body_class));
|
ctx.push(FrameFragment::new(styles, frame).with_class(body_class));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -172,29 +172,17 @@ impl Array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the first item in the array. May be used on the left-hand side
|
/// Returns the first item in the array. May be used on the left-hand side
|
||||||
/// an assignment. Returns the default value if the array is empty
|
/// of an assignment. Fails with an error if the array is empty.
|
||||||
/// or fails with an error is no default value was specified.
|
|
||||||
#[func]
|
#[func]
|
||||||
pub fn first(
|
pub fn first(&self) -> StrResult<Value> {
|
||||||
&self,
|
self.0.first().cloned().ok_or_else(array_is_empty)
|
||||||
/// A default value to return if the array is empty.
|
|
||||||
#[named]
|
|
||||||
default: Option<Value>,
|
|
||||||
) -> StrResult<Value> {
|
|
||||||
self.0.first().cloned().or(default).ok_or_else(array_is_empty)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the last item in the array. May be used on the left-hand side of
|
/// Returns the last item in the array. May be used on the left-hand side of
|
||||||
/// an assignment. Returns the default value if the array is empty
|
/// an assignment. Fails with an error if the array is empty.
|
||||||
/// or fails with an error is no default value was specified.
|
|
||||||
#[func]
|
#[func]
|
||||||
pub fn last(
|
pub fn last(&self) -> StrResult<Value> {
|
||||||
&self,
|
self.0.last().cloned().ok_or_else(array_is_empty)
|
||||||
/// A default value to return if the array is empty.
|
|
||||||
#[named]
|
|
||||||
default: Option<Value>,
|
|
||||||
) -> StrResult<Value> {
|
|
||||||
self.0.last().cloned().or(default).ok_or_else(array_is_empty)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the item at the specified index in the array. May be used on the
|
/// Returns the item at the specified index in the array. May be used on the
|
||||||
|
@ -13,8 +13,8 @@ use crate::math::Mathy;
|
|||||||
/// ```
|
/// ```
|
||||||
#[elem(Mathy)]
|
#[elem(Mathy)]
|
||||||
pub struct AccentElem {
|
pub struct AccentElem {
|
||||||
/// The base to which the accent is applied. May consist of multiple
|
/// The base to which the accent is applied.
|
||||||
/// letters.
|
/// May consist of multiple letters.
|
||||||
///
|
///
|
||||||
/// ```example
|
/// ```example
|
||||||
/// $arrow(A B C)$
|
/// $arrow(A B C)$
|
||||||
@ -51,24 +51,9 @@ pub struct AccentElem {
|
|||||||
pub accent: Accent,
|
pub accent: Accent,
|
||||||
|
|
||||||
/// The size of the accent, relative to the width of the base.
|
/// The size of the accent, relative to the width of the base.
|
||||||
///
|
|
||||||
/// ```example
|
|
||||||
/// $dash(A, size: #150%)$
|
|
||||||
/// ```
|
|
||||||
#[resolve]
|
#[resolve]
|
||||||
#[default(Rel::one())]
|
#[default(Rel::one())]
|
||||||
pub size: Rel<Length>,
|
pub size: Rel<Length>,
|
||||||
|
|
||||||
/// Whether to remove the dot on top of lowercase i and j when adding a top
|
|
||||||
/// accent.
|
|
||||||
///
|
|
||||||
/// This enables the `dtls` OpenType feature.
|
|
||||||
///
|
|
||||||
/// ```example
|
|
||||||
/// $hat(dotless: #false, i)$
|
|
||||||
/// ```
|
|
||||||
#[default(true)]
|
|
||||||
pub dotless: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An accent character.
|
/// An accent character.
|
||||||
@ -118,18 +103,11 @@ macro_rules! accents {
|
|||||||
/// The size of the accent, relative to the width of the base.
|
/// The size of the accent, relative to the width of the base.
|
||||||
#[named]
|
#[named]
|
||||||
size: Option<Rel<Length>>,
|
size: Option<Rel<Length>>,
|
||||||
/// Whether to remove the dot on top of lowercase i and j when
|
|
||||||
/// adding a top accent.
|
|
||||||
#[named]
|
|
||||||
dotless: Option<bool>,
|
|
||||||
) -> Content {
|
) -> Content {
|
||||||
let mut accent = AccentElem::new(base, Accent::new($primary));
|
let mut accent = AccentElem::new(base, Accent::new($primary));
|
||||||
if let Some(size) = size {
|
if let Some(size) = size {
|
||||||
accent = accent.with_size(size);
|
accent = accent.with_size(size);
|
||||||
}
|
}
|
||||||
if let Some(dotless) = dotless {
|
|
||||||
accent = accent.with_dotless(dotless);
|
|
||||||
}
|
|
||||||
accent.pack()
|
accent.pack()
|
||||||
}
|
}
|
||||||
)+
|
)+
|
||||||
|
@ -238,7 +238,7 @@ impl<'s> SmartQuotes<'s> {
|
|||||||
"cs" | "de" | "et" | "is" | "lt" | "lv" | "sk" | "sl" => low_high,
|
"cs" | "de" | "et" | "is" | "lt" | "lv" | "sk" | "sl" => low_high,
|
||||||
"da" => ("‘", "’", "“", "”"),
|
"da" => ("‘", "’", "“", "”"),
|
||||||
"fr" | "ru" if alternative => default,
|
"fr" | "ru" if alternative => default,
|
||||||
"fr" => ("“", "”", "«\u{202F}", "\u{202F}»"),
|
"fr" => ("‹\u{00A0}", "\u{00A0}›", "«\u{00A0}", "\u{00A0}»"),
|
||||||
"fi" | "sv" if alternative => ("’", "’", "»", "»"),
|
"fi" | "sv" if alternative => ("’", "’", "»", "»"),
|
||||||
"bs" | "fi" | "sv" => ("’", "’", "”", "”"),
|
"bs" | "fi" | "sv" => ("’", "’", "”", "”"),
|
||||||
"it" if alternative => default,
|
"it" if alternative => default,
|
||||||
|
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 570 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 651 B After Width: | Height: | Size: 856 B |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 568 B After Width: | Height: | Size: 573 B |
@ -179,10 +179,6 @@
|
|||||||
#test((2,).last(), 2)
|
#test((2,).last(), 2)
|
||||||
#test((1, 2, 3).first(), 1)
|
#test((1, 2, 3).first(), 1)
|
||||||
#test((1, 2, 3).last(), 3)
|
#test((1, 2, 3).last(), 3)
|
||||||
#test((1, 2).first(default: 99), 1)
|
|
||||||
#test(().first(default: 99), 99)
|
|
||||||
#test((1, 2).last(default: 99), 2)
|
|
||||||
#test(().last(default: 99), 99)
|
|
||||||
|
|
||||||
--- array-first-empty ---
|
--- array-first-empty ---
|
||||||
// Error: 2-12 array is empty
|
// Error: 2-12 array is empty
|
||||||
|
@ -42,11 +42,3 @@ $tilde(U, size: #1.1em), x^tilde(U, size: #1.1em), sscript(tilde(U, size: #1.1em
|
|||||||
macron(bb(#c)), dot(cal(#c)), diaer(upright(#c)), breve(bold(#c)),
|
macron(bb(#c)), dot(cal(#c)), diaer(upright(#c)), breve(bold(#c)),
|
||||||
circle(bold(upright(#c))), caron(upright(sans(#c))), arrow(bold(frak(#c)))$
|
circle(bold(upright(#c))), caron(upright(sans(#c))), arrow(bold(frak(#c)))$
|
||||||
$test(i) \ test(j)$
|
$test(i) \ test(j)$
|
||||||
|
|
||||||
--- math-accent-dotless-disabled ---
|
|
||||||
// Test disabling the dotless glyph variants.
|
|
||||||
$hat(i), hat(i, dotless: #false), accent(j, tilde), accent(j, tilde, dotless: #false)$
|
|
||||||
|
|
||||||
--- math-accent-dotless-set-rule ---
|
|
||||||
#set math.accent(dotless: false)
|
|
||||||
$ hat(i) $
|
|
||||||
|
@ -17,6 +17,6 @@ $ x = cases(1, 2) $
|
|||||||
$ cases(a, b, c) $
|
$ cases(a, b, c) $
|
||||||
|
|
||||||
--- math-cases-linebreaks ---
|
--- math-cases-linebreaks ---
|
||||||
// Warning: 40-49 linebreaks are ignored in branches
|
// Currently linebreaks are equivalent to commas, though this behaviour may
|
||||||
// Hint: 40-49 use commas instead to separate each line
|
// change in the future.
|
||||||
$ cases(a, b, c) cases(reverse: #true, a \ b \ c) $
|
$ cases(a, b, c) cases(reverse: #true, a \ b \ c) $
|
||||||
|
@ -256,17 +256,10 @@ $ mat(delim: #(none, "["), 1, 2; 3, 4) $
|
|||||||
$ mat(delim: #(sym.angle.r, sym.bracket.double.r), 1, 2; 3, 4) $
|
$ mat(delim: #(sym.angle.r, sym.bracket.double.r), 1, 2; 3, 4) $
|
||||||
|
|
||||||
--- math-mat-linebreaks ---
|
--- math-mat-linebreaks ---
|
||||||
// Warning: 20-29 linebreaks are ignored in cells
|
// Unlike cases and vectors, linebreaks are discarded in matrices. This
|
||||||
// Hint: 20-29 use commas instead to separate each line
|
// behaviour may change in the future.
|
||||||
$ mat(a; b; c) mat(a \ b \ c) $
|
$ mat(a; b; c) mat(a \ b \ c) $
|
||||||
|
|
||||||
--- math-mat-vec-cases-unity ---
|
|
||||||
// Test that matrices, vectors, and cases are all laid out the same.
|
|
||||||
$ mat(z_(n_p); a^2)
|
|
||||||
vec(z_(n_p), a^2)
|
|
||||||
cases(reverse: #true, delim: \(, z_(n_p), a^2)
|
|
||||||
cases(delim: \(, z_(n_p), a^2) $
|
|
||||||
|
|
||||||
--- issue-1617-mat-align ---
|
--- issue-1617-mat-align ---
|
||||||
#set page(width: auto)
|
#set page(width: auto)
|
||||||
$ mat(a, b; c, d) mat(x; y) $
|
$ mat(a, b; c, d) mat(x; y) $
|
||||||
|
@ -51,6 +51,6 @@ $ vec(1, 2) $
|
|||||||
#set math.vec(delim: (none, "%"))
|
#set math.vec(delim: (none, "%"))
|
||||||
|
|
||||||
--- math-vec-linebreaks ---
|
--- math-vec-linebreaks ---
|
||||||
// Warning: 20-29 linebreaks are ignored in elements
|
// Currently linebreaks are equivalent to commas, though this behaviour may
|
||||||
// Hint: 20-29 use commas instead to separate each line
|
// change in the future.
|
||||||
$ vec(a, b, c) vec(a \ b \ c) $
|
$ vec(a, b, c) vec(a \ b \ c) $
|
||||||
|
@ -99,7 +99,7 @@ He's told some books contain questionable "example text".
|
|||||||
|
|
||||||
--- smartquote-disabled-temporarily ---
|
--- smartquote-disabled-temporarily ---
|
||||||
// Test changing properties within text.
|
// Test changing properties within text.
|
||||||
"She suddenly started speaking french: #text(lang: "fr", region: "CH")['Je suis une banane.']" Roman told me.
|
"She suddenly started speaking french: #text(lang: "fr")['Je suis une banane.']" Roman told me.
|
||||||
|
|
||||||
Some people's thought on this would be #[#set smartquote(enabled: false); "strange."]
|
Some people's thought on this would be #[#set smartquote(enabled: false); "strange."]
|
||||||
|
|
||||||
|