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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃憣 IMPROVE: Ensure len(state.src) == len(state.srcCharCode) #108
Conversation
Thanks for submitting your first pull request! You are awesome! 馃 |
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
==========================================
- Coverage 96.49% 96.46% -0.03%
==========================================
Files 69 69
Lines 2912 2916 +4
==========================================
+ Hits 2810 2813 +3
- Misses 102 103 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I made suggestions that use the @property
decorator to keep API identical to JS markdown-it.
With those changes I believe we can also remove line 10 from the __init__
that sets self.srcCharCode
.
Also, might make sense to add the |
Co-authored-by: Taneli Hukkinen <hukkinj1@users.noreply.github.com>
Co-authored-by: Taneli Hukkinen <hukkinj1@users.noreply.github.com>
Nice suggestions! I have added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove the line
self.srcCharCode = [ord(c) for c in src] if src is not None else []
in StateInline.__init__
.
In StateBlock.__init__
we can make the lines
self.src = src
if srcCharCode is not None:
self.srcCharCode = srcCharCode
else:
self.srcCharCode = [ord(c) for c in src] if src is not None else []
something like
if srcCharCode is not None:
self._src = src
self.srcCharCode = srcCharCode
else:
self.src = src
This will keep the (presumably) performance improvement in place.
Co-authored-by: Taneli Hukkinen <hukkinj1@users.noreply.github.com>
Looking good @geebos ! Did you see this comment #108 (review) . You think those two changes can be used here too? |
Thanks for reminding. I have added a |
What makes you think so? I believe this should work just fine as long as there's only one preceding underscore ( class StateBase:
_src: str |
You are right. I confuse them. |
Nice, this looks very good to me! |
thanks! |
When updating state.src, state.srcCharCode should be updated synchronously.