diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 2839baff6..4a820a840 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -101,7 +101,7 @@ impl Eval for MarkupNode { Ok(match self { Self::Space => Content::Space, Self::Parbreak => Content::Parbreak, - Self::Linebreak(soft) => Content::Linebreak(*soft), + Self::Linebreak(justified) => Content::Linebreak(*justified), Self::Text(text) => Content::Text(text.clone()), Self::Quote(double) => Content::Quote(*double), Self::Strong(strong) => strong.eval(ctx, scp)?, diff --git a/src/library/text/par.rs b/src/library/text/par.rs index 17fcea75e..4694993ec 100644 --- a/src/library/text/par.rs +++ b/src/library/text/par.rs @@ -168,8 +168,8 @@ pub struct LinebreakNode; #[node] impl LinebreakNode { fn construct(_: &mut Context, args: &mut Args) -> TypResult { - let soft = args.named("soft")?.unwrap_or(false); - Ok(Content::Linebreak(soft)) + let justified = args.named("justified")?.unwrap_or(false); + Ok(Content::Linebreak(justified)) } } diff --git a/src/model/content.rs b/src/model/content.rs index 03153684d..4077f6963 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -39,8 +39,8 @@ use crate::util::EcoString; pub enum Content { /// A word space. Space, - /// A forced line break. If soft (`true`), the preceding line can still be - /// justified, if hard (`false`) not. + /// A forced line break. If `true`, the preceding line can still be + /// justified, if `false` not. Linebreak(bool), /// Horizontal spacing. Horizontal(Spacing), @@ -234,7 +234,7 @@ impl Debug for Content { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::Space => f.pad("Space"), - Self::Linebreak(soft) => write!(f, "Linebreak({soft})"), + Self::Linebreak(justified) => write!(f, "Linebreak({justified})"), Self::Horizontal(kind) => write!(f, "Horizontal({kind:?})"), Self::Text(text) => write!(f, "Text({text:?})"), Self::Quote(double) => write!(f, "Quote({double})"), @@ -397,8 +397,8 @@ impl<'a> Builder<'a> { Content::Space => { self.par.weak(ParChild::Text(' '.into()), 0, styles); } - Content::Linebreak(soft) => { - let c = if *soft { '\u{2028}' } else { '\n' }; + Content::Linebreak(justified) => { + let c = if *justified { '\u{2028}' } else { '\n' }; self.par.destructive(ParChild::Text(c.into()), styles); } Content::Horizontal(kind) => { diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 82bb7d563..5232b1f15 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -62,7 +62,7 @@ impl Markup { self.0.children().filter_map(|node| match node.kind() { NodeKind::Space(2 ..) => Some(MarkupNode::Parbreak), NodeKind::Space(_) => Some(MarkupNode::Space), - NodeKind::Linebreak(s) => Some(MarkupNode::Linebreak(*s)), + NodeKind::Linebreak(j) => Some(MarkupNode::Linebreak(*j)), NodeKind::Text(s) => Some(MarkupNode::Text(s.clone())), NodeKind::Escape(c) => Some(MarkupNode::Text((*c).into())), NodeKind::NonBreakingSpace => Some(MarkupNode::Text('\u{00A0}'.into())), @@ -88,8 +88,8 @@ impl Markup { pub enum MarkupNode { /// Whitespace containing less than two newlines. Space, - /// A forced line break. If soft (`\`, `true`), the preceding line can still - /// be justified, if hard (`\+`, `false`) not. + /// A forced line break. If `true` (`\`), the preceding line can still be + /// justified, if `false` (`\+`) not. Linebreak(bool), /// A paragraph break: Two or more newlines. Parbreak, diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index 00bcb376c..2272b3e03 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -588,8 +588,8 @@ pub enum NodeKind { Space(usize), /// A consecutive non-markup string. Text(EcoString), - /// A forced line break. If soft (`\`, `true`), the preceding line can still - /// be justified, if hard (`\+`, `false`) not. + /// A forced line break. If `true` (`\`), the preceding line can still be + /// justified, if `false` (`\+`) not. Linebreak(bool), /// A non-breaking space: `~`. NonBreakingSpace, @@ -867,8 +867,8 @@ impl NodeKind { Self::Markup(_) => "markup", Self::Space(2 ..) => "paragraph break", Self::Space(_) => "space", - Self::Linebreak(false) => "hard linebreak", - Self::Linebreak(true) => "soft linebreak", + Self::Linebreak(false) => "linebreak", + Self::Linebreak(true) => "justified linebreak", Self::Text(_) => "text", Self::NonBreakingSpace => "non-breaking space", Self::Shy => "soft hyphen", diff --git a/tests/ref/text/linebreak.png b/tests/ref/text/linebreak.png index 4a691d72a..1a3f49dfc 100644 Binary files a/tests/ref/text/linebreak.png and b/tests/ref/text/linebreak.png differ diff --git a/tests/typ/text/linebreak.typ b/tests/typ/text/linebreak.typ index bee17c6bc..797e2f7c9 100644 --- a/tests/typ/text/linebreak.typ +++ b/tests/typ/text/linebreak.typ @@ -13,7 +13,7 @@ Supercalifragilisticexpialidocious Expialigoricmetrioxidation. This is partly emp#emph[has]ized. --- -Hard \ break. +Hard #linebreak() break. --- // Test hard break directly after normal break. @@ -21,13 +21,16 @@ Hard break directly after \ normal break. --- // Test consecutive breaks. -Two consecutive \ \ breaks and three \ \ \ more. +Two consecutive \ \ breaks and three \ \ more. --- // Test forcing an empty trailing line. Trailing break \ \ --- -// Test soft breaks. +// Test justified breaks. #set par(justify: true) -With a soft \+ break you can force a break without breaking justification. +With a soft \+ +break you can force a break without #linebreak(justified: true) +breaking justification. #linebreak(justified: false) +Nice!