3 unstable releases

0.2.1 Aug 7, 2024
0.2.0 Jul 30, 2024
0.1.0 Jun 18, 2024

#188 in Programming languages

Download history 124/week @ 2024-06-12 70/week @ 2024-06-19 431/week @ 2024-06-26 339/week @ 2024-07-03 340/week @ 2024-07-10 347/week @ 2024-07-17 369/week @ 2024-07-24 312/week @ 2024-07-31 391/week @ 2024-08-07 475/week @ 2024-08-14 306/week @ 2024-08-21 255/week @ 2024-08-28

1,469 downloads per month
Used in 7 crates (2 directly)

MIT license

27KB
452 lines

codesnake

codesnake is a Rust crate that shows code blocks and labels parts of it. Its name comes from the snake-like appearance of the lines that connect code spans with their corresponding labels. 🐍 An example of its output:

Example output

Features

  • Uses &str as code input and byte positions for spans
  • Multiple spans within a code block
  • Spans may range over multiple lines
  • Zero dependencies

While this crate does not support colored output out of the box, it is very easy to integrate it with other crates like yansi to produce colored output for the terminal (ANSI) and web (HTML).

  • ariadne: I used ariadne happily myself for quite some time, but it had broken semantic versioning for at least one month now, which led to build failures in a project of mine. Furthermore, the heart of this crate is a function more than 700 lines long, of which the author himself states that it is complex, has bugs and needs rewriting. codesnake can be considered to be a rewrite of ariadne, focusing on its core features.
  • codespan-reporting: This seems to be the spiritual predecessor of ariadne, but it looks unfortunately unmaintained, with the last release from 2021.
  • miette: This seems to be a pretty popular library nowadays for code span reporting. However, to me it looks intimidatingly complex and provides much more functionality than I need. Furthermore, it has a higher MSRV and more dependencies than I like. But, the real deal breaker for me is that according to its description, it is "for us mere mortals who aren't compiler hackers". Given that I see myself as some kind of compiler hacker, I do not feel as part of its target group (although I'm probably mortal). :)

No runtime deps