Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

begin <= end (15 <= 6) when slicing #2

Open
webxxxxx opened this issue Apr 1, 2024 · 0 comments
Open

begin <= end (15 <= 6) when slicing #2

webxxxxx opened this issue Apr 1, 2024 · 0 comments

Comments

@webxxxxx
Copy link

webxxxxx commented Apr 1, 2024

fn highlight(snippet: Snippet) -> String {
let mut result = String::new();
let mut start_from = 0;

for fragment_range in snippet.highlighted() {
    result.push_str(&snippet.fragment()[**start_from..fragment_range.start]**);
    result.push_str("<font color='red'>");
    result.push_str(&snippet.fragment()[fragment_range.clone()]);
    result.push_str("</font>");
    start_from = fragment_range.end;
}

result.push_str(&snippet.fragment()[start_from..]);
result

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant