diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-13 14:48:19 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-13 14:48:19 +0200 |
| commit | 67e9313b9127b70b9d7dad6540853025ae90b4a5 (patch) | |
| tree | 9f060b1982534ad67ee5a0688927071aa08dd96c /src/syntax/mod.rs | |
| parent | 2279c26543f7edde910fd89a3f8f0710c67249db (diff) | |
Soft breaks and shy hyphens
Diffstat (limited to 'src/syntax/mod.rs')
| -rw-r--r-- | src/syntax/mod.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index f0d3cdd4..1f02217a 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -586,12 +586,15 @@ pub enum NodeKind { Markup(usize), /// One or more whitespace characters. Space(usize), - /// A forced line break: `\`. - Linebreak, /// 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. + Linebreak(bool), /// A non-breaking space: `~`. NonBreakingSpace, + /// A soft hyphen: `-?`. + Shy, /// An en-dash: `--`. EnDash, /// An em-dash: `---`. @@ -766,7 +769,7 @@ impl NodeKind { pub fn only_in_mode(&self) -> Option<TokenMode> { match self { Self::Markup(_) - | Self::Linebreak + | Self::Linebreak(_) | Self::Text(_) | Self::NonBreakingSpace | Self::EnDash @@ -859,9 +862,11 @@ impl NodeKind { Self::Markup(_) => "markup", Self::Space(2 ..) => "paragraph break", Self::Space(_) => "space", - Self::Linebreak => "forced linebreak", + Self::Linebreak(false) => "hard linebreak", + Self::Linebreak(true) => "soft linebreak", Self::Text(_) => "text", Self::NonBreakingSpace => "non-breaking space", + Self::Shy => "soft hyphen", Self::EnDash => "en dash", Self::EmDash => "em dash", Self::Quote(false) => "single quote", @@ -981,9 +986,10 @@ impl Hash for NodeKind { Self::From => {} Self::Markup(c) => c.hash(state), Self::Space(n) => n.hash(state), - Self::Linebreak => {} + Self::Linebreak(s) => s.hash(state), Self::Text(s) => s.hash(state), Self::NonBreakingSpace => {} + Self::Shy => {} Self::EnDash => {} Self::EmDash => {} Self::Quote(d) => d.hash(state), |
