diff options
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/content.rs | 14 | ||||
| -rw-r--r-- | src/eval/mod.rs | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/eval/content.rs b/src/eval/content.rs index 274b64b0..605abe51 100644 --- a/src/eval/content.rs +++ b/src/eval/content.rs @@ -39,8 +39,9 @@ use crate::util::EcoString; pub enum Content { /// A word space. Space, - /// A line break. - Linebreak, + /// A forced line break. If soft (`true`), the preceding line can still be + /// justified, if hard (`false`) not. + Linebreak(bool), /// Horizontal spacing. Horizontal(Spacing), /// Plain text. @@ -213,10 +214,10 @@ impl Debug for Content { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::Space => f.pad("Space"), - Self::Linebreak => f.pad("Linebreak"), + Self::Linebreak(soft) => write!(f, "Linebreak({soft})"), Self::Horizontal(kind) => write!(f, "Horizontal({kind:?})"), Self::Text(text) => write!(f, "Text({text:?})"), - Self::Quote(double) => write!(f, "Quote({double:?})"), + Self::Quote(double) => write!(f, "Quote({double})"), Self::Inline(node) => { f.write_str("Inline(")?; node.fmt(f)?; @@ -376,8 +377,9 @@ impl<'a> Builder<'a> { Content::Space => { self.par.weak(ParChild::Text(' '.into()), 0, styles); } - Content::Linebreak => { - self.par.destructive(ParChild::Text('\n'.into()), styles); + Content::Linebreak(soft) => { + let c = if *soft { '\u{2028}' } else { '\n' }; + self.par.destructive(ParChild::Text(c.into()), styles); } Content::Horizontal(kind) => { let child = ParChild::Spacing(*kind); diff --git a/src/eval/mod.rs b/src/eval/mod.rs index f2c03c0f..4a616b58 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -108,8 +108,8 @@ impl Eval for MarkupNode { fn eval(&self, ctx: &mut Context, scp: &mut Scopes) -> EvalResult<Self::Output> { Ok(match self { Self::Space => Content::Space, - Self::Linebreak => Content::Linebreak, Self::Parbreak => Content::Parbreak, + Self::Linebreak(soft) => Content::Linebreak(*soft), Self::Text(text) => Content::Text(text.clone()), Self::Quote(double) => Content::Quote(*double), Self::Strong(strong) => strong.eval(ctx, scp)?, |
