diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-01-30 12:50:58 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-01-30 22:46:59 +0100 |
| commit | 8d1ce390e21ce0a5812a4211c893ec359906d6f1 (patch) | |
| tree | 5dbe1ad96af8ce8f9f01887340fe06025462e959 /src/syntax/highlight.rs | |
| parent | d7072f378fef733ae994fd9a1e767df4e4dd878e (diff) | |
Rework strong and emph
- Star and underscore not parsed as strong/emph inside of words
- Stars/underscores must be balanced and they cannot go over paragraph break
- New `strong` and `emph` classes
Diffstat (limited to 'src/syntax/highlight.rs')
| -rw-r--r-- | src/syntax/highlight.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/syntax/highlight.rs b/src/syntax/highlight.rs index 315e8f17..b806b4e4 100644 --- a/src/syntax/highlight.rs +++ b/src/syntax/highlight.rs @@ -151,7 +151,10 @@ impl Category { NodeKind::From => Some(Category::Keyword), NodeKind::Include => Some(Category::Keyword), NodeKind::Plus => Some(Category::Operator), - NodeKind::Star => Some(Category::Operator), + NodeKind::Star => match parent.kind() { + NodeKind::Strong => None, + _ => Some(Category::Operator), + }, NodeKind::Slash => Some(Category::Operator), NodeKind::PlusEq => Some(Category::Operator), NodeKind::HyphEq => Some(Category::Operator), @@ -191,6 +194,7 @@ impl Category { NodeKind::Str(_) => Some(Category::String), NodeKind::Error(_, _) => Some(Category::Invalid), NodeKind::Unknown(_) => Some(Category::Invalid), + NodeKind::Underscore => None, NodeKind::Markup(_) => None, NodeKind::Space(_) => None, NodeKind::Parbreak => None, @@ -276,11 +280,7 @@ mod tests { assert_eq!(vec, goal); } - test("= *AB*", &[ - (0 .. 6, Heading), - (2 .. 3, Strong), - (5 .. 6, Strong), - ]); + test("= *AB*", &[(0 .. 6, Heading), (2 .. 6, Strong)]); test("#f(x + 1)", &[ (0 .. 2, Function), |
