summaryrefslogtreecommitdiff
path: root/src/eval/content.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-13 14:48:19 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-13 14:48:19 +0200
commit67e9313b9127b70b9d7dad6540853025ae90b4a5 (patch)
tree9f060b1982534ad67ee5a0688927071aa08dd96c /src/eval/content.rs
parent2279c26543f7edde910fd89a3f8f0710c67249db (diff)
Soft breaks and shy hyphens
Diffstat (limited to 'src/eval/content.rs')
-rw-r--r--src/eval/content.rs14
1 files changed, 8 insertions, 6 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);