Skip to content

Commit

Permalink
Allow parsing inherit_parent as cursup style
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Jun 20, 2024
1 parent 3f511e1 commit e37530f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cursive-core/src/utils/markup/cursup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub fn parse_spans(input: &str) -> Vec<StyledIndexedSpan> {
}
(State::Plain, _) => (),

(State::Slash(_), b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'#' | b'+' | b'.') => (),
(
State::Slash(_),
b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'#' | b'+' | b'.' | b'_',
) => (),
(State::Slash(slash), b'{') => {
// Add a candidate.
candidates.push(Candidate {
Expand Down Expand Up @@ -158,7 +161,7 @@ where

#[cfg(test)]
mod tests {
use crate::theme::{BaseColor, Color, Effect, Style};
use crate::theme::{BaseColor, Color, ColorType, Effect, Style};
use crate::utils::markup::cursup::parse;
use crate::utils::markup::StyledString;
use crate::utils::span::Span;
Expand Down Expand Up @@ -238,6 +241,20 @@ mod tests {
);
}

#[test]
fn inherit_parent() {
let parsed = parse("/inherit_parent{foo}");
let spans: Vec<_> = parsed.spans().collect();
assert_eq!(
&spans,
&[Span {
content: "foo",
width: 3,
attr: &Style::from_color_style(ColorType::InheritParent.into()),
}]
);
}

#[test]
fn hex_color() {
let parsed = parse("/#ff0000{red}");
Expand Down

0 comments on commit e37530f

Please sign in to comment.