-
Notifications
You must be signed in to change notification settings - Fork 74
👌 IMPROVE: Add RendererProtocol
typing
#126
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
Changes from 6 commits
20f40c7
81f353f
62e16c1
9d37f8c
a379e2a
344dbb0
be440b3
71e6c38
ef87743
cc1214e
834e239
d2bf9b5
14f64e0
f9615ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,13 +6,35 @@ class Renderer | |||||||||||||||||
rules if you create plugin and adds new token types. | ||||||||||||||||||
""" | ||||||||||||||||||
import inspect | ||||||||||||||||||
from typing import Optional, Sequence | ||||||||||||||||||
import sys | ||||||||||||||||||
from typing import ( | ||||||||||||||||||
Any, | ||||||||||||||||||
ClassVar, | ||||||||||||||||||
Mapping, | ||||||||||||||||||
MutableMapping, | ||||||||||||||||||
Optional, | ||||||||||||||||||
Sequence, | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
from .common.utils import unescapeAll, escapeHtml | ||||||||||||||||||
from .token import Token | ||||||||||||||||||
|
||||||||||||||||||
if sys.version_info < (3, 8): | ||||||||||||||||||
from typing_extensions import Protocol | ||||||||||||||||||
else: | ||||||||||||||||||
from typing import Protocol | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I've literally just has an issue where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. Please let me know what the issue was. I'm very interested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually turned out to be an issue with importing of But anyhow, I think this approach is still slightly "safer" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so conda not doing the name normalization if I understand correctly? Good to know, thanks! I don't use Conda so no need to change any of my personal projects 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeh seems to be the case 😬 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. despite that it is generally very good; particularly in resolving/enforcing dependency versions and/or if you are using non-python dependencies |
||||||||||||||||||
|
||||||||||||||||||
class RendererHTML: | ||||||||||||||||||
|
||||||||||||||||||
class RendererProtocol(Protocol): | ||||||||||||||||||
__output__: ClassVar[str] | ||||||||||||||||||
|
||||||||||||||||||
def render( | ||||||||||||||||||
self, tokens: Sequence[Token], options: Mapping[str, Any], env: MutableMapping | ||||||||||||||||||
hukkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
) -> str: | ||||||||||||||||||
hukkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
... | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
class RendererHTML(RendererProtocol): | ||||||||||||||||||
"""Contains render rules for tokens. Can be updated and extended. | ||||||||||||||||||
|
||||||||||||||||||
Example: | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.