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

feature: HTMLSerializer - custom fallback for .serialize #422

Open
jvanasco opened this issue Jul 1, 2019 · 0 comments
Open

feature: HTMLSerializer - custom fallback for .serialize #422

jvanasco opened this issue Jul 1, 2019 · 0 comments

Comments

@jvanasco
Copy link
Contributor

jvanasco commented Jul 1, 2019

HTMLSerializer.serialize has a chained if/else that ends with this:

        else:
            self.serializeError(token["data"])

I propose supporting a custom fallback method that would allow subclasses to invoke the benefit of this serializer's method to deal with unknown/custom token types. this would allow custom parsers/tree-adapters the ability to override how something is rendered by changing the token type and registering a custom handler... which still leveraging the core serializer.

for example:

        else:
            if self._customTypes and (type in self._customTypes):
                 yield self.self._customTypes[type](token)
            else:
                self.serializeError(token["data"])
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

1 participant