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

Tracking issue: Typst support #147

Open
3 tasks
alexpovel opened this issue Oct 10, 2024 · 5 comments
Open
3 tasks

Tracking issue: Typst support #147

alexpovel opened this issue Oct 10, 2024 · 5 comments

Comments

@alexpovel
Copy link
Owner

TODO:

  • richer Typst support, WIP at https://github.com/alexpovel/srgn/tree/typst

  • make it useful with type checking (aspell), for which the text node type seems most useful

  • which requires piping into aspell, for which srgn currently doesn't have good support. Probably needs refactoring the crappy apply function:

    fn apply(

    so its output is something like (command run on commit 47be5f0)

    [filename if not stdin];linenum;startcol;endcol: text
    

    e.g. (numbers made up)

    $ cat tests/langs/typst/base.typ | c run -- -j --typ text --typ strings
    [...snip...]
    62;12;13: In case you missed it, there's a recording on
    62;58;62: "http://purview.edu/lts/2023-lee"

    i.e., it doesn't print non-text nodes such as #link(, as it currently does:

    image

cc @ju6ge

@alexpovel
Copy link
Owner Author

Kinda blocked, as I'd prefer not vendoring and only using grammars part of the tree-sitter org. Otherwise, it can get pretty painful with updates and keeping things in sync (see HCL support in srgn).

@lysogeny
Copy link

For spell checking I was wondering if it might be sufficient to strip out the markup, similar to what the TeX tool detex does, only making this print the selected nodes in some mode. The resulting file could then be piped into a user's favourite spellchecker and should, for that task, probably be good enough?

@ju6ge
Copy link

ju6ge commented Nov 20, 2024

For me the interesting use case would be CI Pipelines. In that case it would be interesting be able to map the spelling error to the line and column of the file in which it occurred. But for that srgn would need to print the filename and line numbers, so that downstream tools could keep track of it correctly. (It does this currently but not in a from that is easily pipeable…) On the other hand I have yet to find a spell checker that will actually give me the desired output to make this work correctly, they seems to either only print a list of misspelled words or use a custom stream format to not just show the misspelled word, but also suggest fixes.

@alexpovel
Copy link
Owner Author

Thanks for your thoughts!

I had considered skipping the whole part about "if srgn is piped into something that is not a terminal, use machine-friendly/parseable output" and instead just offer JSON output. That's much more flexible, and (probably) easier to implement at the same time. It avoids work on my side (coming up with a parse-friendly format), but also allows full flexibility on the reading side of the pipe. It could look like srgn --whatever | jq '.whatever' | spellcheck. You would "only" need to massage the jq query, which is infinitely more powerful than what srgn could ever offer (and an LLM could probably write it very well for you). Let me know if you have any thoughts on that.

(work on srgn is currently slow, sorry!)

@ju6ge
Copy link

ju6ge commented Nov 20, 2024

I am not opposed to json. Might very well be more flexible when transformed with jq. The blocker on my side ist that I have not found a spell checking tool gives me simple enough output that can be further processed easily. So no need to apologise for slow development.

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

3 participants