Rename soft linebreak to justified linebreak
This commit is contained in:
parent
2791f59ce2
commit
2f33ad0e0a
@ -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)?,
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) => {
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@ -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!
|
||||
|
Loading…
Reference in New Issue
Block a user