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

Allow multiple node return #2713

Merged
merged 12 commits into from
Nov 15, 2023
Merged

Allow multiple node return #2713

merged 12 commits into from
Nov 15, 2023

Conversation

tabatkins
Copy link
Collaborator

@tabatkins tabatkins commented Nov 15, 2023

Before I can start recognizing shorthands (which might have parseable HTML inside of them) in the parser, I need the ability to return multiple nodes from a single parseNode call.

While I was here, I did a little more cleanup:

  • the curly-quote replacement is now done on text nodes post-production, rather than part of parseNode
  • Stream now caches its length, to speed up .eof() calls. (I presume the chars are immutable anyway.)
  • Nodes can now decrement the line count as well, if they end up producing more lines than what they occupied in the source. (This can happen in multiline markdown code spans; previously it was hidden by me emitting the whole thing as a single node, so me removing newlines from the text but adding them to the start tag in an attribute was a wash.)
  • Result is now properly generic in its contained type, so I can debug better, rather than just spewing Any all over. I went ahead and moved away from the slightly silly "return the Failure class itself" design, instead using None as the marker; if None is a valid value you can just get the full val/i/error triple to check for success.
  • A limitation of mypy is that it can't express an iterator that returns different types for each iteration. So I had to abandon using __iter__ to return the (value, i) tuple, instead just requiring you to specifically request the .t2 tuple from each result. (or .t3 to get the error, or just the .value or .i if that's all you need).

@tabatkins tabatkins merged commit 212ecfa into main Nov 15, 2023
3 checks passed
@tabatkins tabatkins deleted the allow-multiple-node-return branch November 15, 2023 20:55
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