summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-24 21:36:41 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-24 21:38:23 +0200
commit2f33ad0e0aa3d1f4a949025597bf1ea36256831f (patch)
treec98bff188e35d0836384418c7da1635660b10fe7
parent2791f59ce2404d0483aee92b8231df95aa45b7a5 (diff)
Rename soft linebreak to justified linebreak
-rw-r--r--src/eval/mod.rs2
-rw-r--r--src/library/text/par.rs4
-rw-r--r--src/model/content.rs10
-rw-r--r--src/syntax/ast.rs6
-rw-r--r--src/syntax/mod.rs8
-rw-r--r--tests/ref/text/linebreak.pngbin18653 -> 18957 bytes
-rw-r--r--tests/typ/text/linebreak.typ11
7 files changed, 22 insertions, 19 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 2839baff..4a820a84 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 17fcea75..4694993e 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<Content> {
- 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 03153684..4077f696 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 82bb7d56..5232b1f1 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 00bcb376..2272b3e0 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 4a691d72..1a3f49df 100644
--- a/tests/ref/text/linebreak.png
+++ b/tests/ref/text/linebreak.png
Binary files differ
diff --git a/tests/typ/text/linebreak.typ b/tests/typ/text/linebreak.typ
index bee17c6b..797e2f7c 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!