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

Make StopIteration Errors more informative #38

Closed
amichuda opened this issue Aug 31, 2020 · 3 comments
Closed

Make StopIteration Errors more informative #38

amichuda opened this issue Aug 31, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@amichuda
Copy link

Oftentimes when running codebraid, I get a StopIteration error and it is difficult to tell where this error comes from. Is there a way to make the StopIteration error more informative, like giving the snippet of text that causes the issue or the line number?

@gpoore
Copy link
Owner

gpoore commented Sep 2, 2020

The StopIteration errors happen when codebraid fails to sync code with a corresponding line number in the document. Pandoc's AST doesn't contain any information about source document locations, so as codebraid goes through the Pandoc AST looking for code to execute, it also performs searches to determine the current location in the document. Whenever it finds code or text in the AST, it does a search from the last location reached in the document to find that code or text. The issue is that sometimes Pandoc modifies code or text in one way or another while creating the AST, so the search can fail and result in StopIteration.

The real solution for this will be a better, more robust search algorithm. I had hoped that the fix for #36 would handle all remaining issues, but apparently that's not the case. A new algorithm should probably give up when text isn't found within a couple of lines. I believe the searches for code should all succeed at this point, since HTML is skipped to avoid modifications made by Pandoc. There should also be a fallback to using something like ?? for source document line numbers in the event that things still fail.

@gpoore
Copy link
Owner

gpoore commented Apr 28, 2021

This entire category of errors from syncing code to source line numbers should be permanently eliminated by the last commit. Sorry for the long delay.

@amichuda
Copy link
Author

No worries, this is great!

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

No branches or pull requests

2 participants