Skip to content

Align API for Modest / Lexbor implementations #140

@JuroOravec

Description

@JuroOravec

As I was looking at #138, I noticed in the codebase that the issue around decoding was already addressed for HTMLParser class (Modest impl), but not for LexborHMLParser (Lexbor impl).

Also it can be error prone, having to check two different places. So to make it easier to maintain, preferably there would be a single source of truth for the public API, while the implementation-specific C code would be abstracted away.

It could look maybe something like this:

class ModestParserImpl:
    def get_body(self, myhtml_tree_t* html_tree):
        cdef myhtml_tree_node_t* body
        body = myhtml_tree_get_node_body(html_tree)
		return body

class LexborParserImpl:
    ...

class HTMLParserABC:
    self.impl = None

    @property
    def body(self):
        cdef myhtml_tree_node_t* body
        body = self.impl.get_body(self.html_tree)

        if body != NULL:
            node = Node()
            node._init(body, self)
            return node

        return None

class HTMLParser(HTMLParserABC):
    impl = ModestParserImpl()

class HTMLParser(HTMLParserABC):
    self.impl = ParserImpl(self)
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions