Skip to content

Conversation

@hippietrail
Copy link
Collaborator

@hippietrail hippietrail commented Dec 7, 2025

Issues

N/A

Description

Formats a lint match with surrounding context for debug output.

This is a handy little tool for when you're working on a new ExprLinter.

Using the new match_to_lint_with_context method it will print the run of text that matches, along with the text before and after it dimmed using ANSI escape codes.

This can help you hone in your Expr before you start working on extracting the lint.
When you're wondering about false positives or trying to sort them out, this helps you see what the most common previous or next words, or several words tend to be.

It does its best to filter out distracting markup that's sometimes between tokens and printed if you just do toks.span()?.get_content_string(src) since that will get everything between the start and the end. You would've seen this when linting Markdown files containing HTML on the command line.

Works great from cargo test or via the smarts in the editor and Rust LSP, and works really great from the new harper-cli lint run over a directory full of files.

Demo

Screenshot 2025-12-07 at 11 35 49 pm

The ❤️ is not included, I just like it to make messages stand out in the log (-:

How Has This Been Tested?

Manually.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

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

Successfully merging this pull request may close these issues.

1 participant