# Path: draftjs_exporter/engines/base.py
# class DOMEngine(object):
#     def create_tag(type_: Tag, attr: Optional[Attr] = None) -> Any:
#     def parse_html(markup: HTML) -> Element:
#     def append_child(elt: Element, child: Element) -> Any:
#     def render(elt: Element) -> HTML:
#     def render_debug(elt: Element) -> HTML:
# 
# Path: draftjs_exporter/types.py
# HTML = str


import re
from typing import Optional
from draftjs_exporter.engines.base import Attr, DOMEngine
from draftjs_exporter.types import HTML, Tag
    from lxml import etree, html


try:
except ImportError:
    pass

NSMAP = {"xlink": "http://www.w3.org/1999/xlink"}

RENDER_RE = re.compile(r"</?fragment>")


class DOM_LXML(DOMEngine):
    """
    lxml implementation of the DOM API.
    """

    @staticmethod
    def create_tag(type_: Tag, attr: Optional[Attr] = None) -> etree.Element:
        nsmap = None

        if attr:
            if "xlink:href" in attr:
                attr[f"{{{NSMAP['xlink']}}}href"] = attr.pop("xlink:href")
                nsmap = NSMAP

        return etree.Element(type_, attrib=attr, nsmap=nsmap)

    @staticmethod

# Path: draftjs_exporter/engines/base.py
# class DOMEngine(object):
#     def create_tag(type_: Tag, attr: Optional[Attr] = None) -> Any:
#     def parse_html(markup: HTML) -> Element:
#     def append_child(elt: Element, child: Element) -> Any:
#     def render(elt: Element) -> HTML:
#     def render_debug(elt: Element) -> HTML:
# 
# Path: draftjs_exporter/types.py
# HTML = str


# Path: draftjs_exporter/engines/lxml.py
import re
from typing import Optional
from draftjs_exporter.engines.base import Attr, DOMEngine
from draftjs_exporter.types import HTML, Tag
    from lxml import etree, html



try:
except ImportError:
    pass

NSMAP = {"xlink": "http://www.w3.org/1999/xlink"}

RENDER_RE = re.compile(r"</?fragment>")


class DOM_LXML(DOMEngine):
    """
    lxml implementation of the DOM API.
    """

    @staticmethod
    def create_tag(type_: Tag, attr: Optional[Attr] = None) -> etree.Element:
        nsmap = None

        if attr:
            if "xlink:href" in attr:
                attr[f"{{{NSMAP['xlink']}}}href"] = attr.pop("xlink:href")
                nsmap = NSMAP

        return etree.Element(type_, attrib=attr, nsmap=nsmap)

    @staticmethod

    def parse_html(markup: HTML) -> etree.Element: