annotate-snippets-rs
annotate-snippets-rs copied to clipboard
Library for snippet annotations
```rust use std::fs; use std::path::PathBuf; use annotate_snippets::display_list::{DisplayList, FormatOptions}; use annotate_snippets::snippet::{AnnotationType, Slice, Snippet, SourceAnnotation}; fn main() { let sql = fs::read_to_string(PathBuf::from("21.sql")).unwrap(); let source = sql.as_str(); println!("source: {:?}", source); println!("capture: {}", &source[51..52]);...
Result: ``` | 0 | SELECT bar | ^^^ unexpected token | ^^^^^^^^^^ while parsing statement | ``` As you can see the `|` is not aligned. Code: ```rust pub(crate)...
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [toml](https://togithub.com/toml-rs/toml) | dev-dependencies | minor | `0.5.11` -> `0.8.0` | --- ### Release...
[](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | Pending | |---|---|---|---| | [rust](https://togithub.com/rust-lang/rust) | minor | `1.73` -> `1.76` | `1.78` (+1) |...
This is inspired by #114 where someone wanted to include a lot of details in the "title" but assumed they couldn't.
In general the new API in 0.11 works nicely, but one pain point I had was mapping `Option` values (which I either calculate on the fly or have stored in...
I wrote a test to demonstrate this: ```rust #[test] fn lf_in_crlf() { let source = "a\r\nb"; let input = Level::Error.title("").snippet( Snippet::source(source) .origin("file/path") .line_start(3) .annotation(Level::Error.span(2..3)), // \n ); let expected =...
I wrote a test to demonstrate this: ```rust #[test] fn unterminated_string_multiline() { let source = "\ a\" // ... "; let input = Level::Error.title("").snippet( Snippet::source(source) .origin("file/path") .line_start(3) .fold(true) .annotation(Level::Error.span(0..10)), //...
#109 fixed an inconsistency in how we folded code before and after all of the annotations. Callers would likely want to control how much context is shown around each annotation.
The `toml` crate occasionally returns empty spans and #107 fixed it so we could render something but it might be useful to try to highlight the space between characters, rather...