Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions html5lib/filters/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
_ = gettext

from . import _base
from html5lib.constants import cdataElements, rcdataElements, voidElements
from ..constants import cdataElements, rcdataElements, voidElements

from html5lib.constants import spaceCharacters
from ..constants import spaceCharacters
spaceCharacters = "".join(spaceCharacters)


Expand Down
2 changes: 1 addition & 1 deletion html5lib/filters/sanitizer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, unicode_literals

from . import _base
from html5lib.sanitizer import HTMLSanitizerMixin
from ..sanitizer import HTMLSanitizerMixin


class Filter(_base.Filter, HTMLSanitizerMixin):
Expand Down
2 changes: 1 addition & 1 deletion html5lib/filters/whitespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from . import _base
from html5lib.constants import rcdataElements, spaceCharacters
from ..constants import rcdataElements, spaceCharacters
spaceCharacters = "".join(spaceCharacters)

SPACES_REGEX = re.compile("[%s]+" % spaceCharacters)
Expand Down
2 changes: 1 addition & 1 deletion html5lib/serializer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, unicode_literals

from html5lib import treewalkers
from .. import treewalkers

from .htmlserializer import HTMLSerializer

Expand Down
14 changes: 7 additions & 7 deletions html5lib/serializer/htmlserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
except ImportError:
pass

from html5lib.constants import voidElements, booleanAttributes, spaceCharacters
from html5lib.constants import rcdataElements, entities, xmlEntities
from html5lib import utils
from ..constants import voidElements, booleanAttributes, spaceCharacters
from ..constants import rcdataElements, entities, xmlEntities
from .. import utils
from xml.sax.saxutils import escape

spaceCharacters = "".join(spaceCharacters)
Expand Down Expand Up @@ -177,18 +177,18 @@ def serialize(self, treewalker, encoding=None):
in_cdata = False
self.errors = []
if encoding and self.inject_meta_charset:
from html5lib.filters.inject_meta_charset import Filter
from ..filters.inject_meta_charset import Filter
treewalker = Filter(treewalker, encoding)
# XXX: WhitespaceFilter should be used before OptionalTagFilter
# for maximum efficiently of this latter filter
if self.strip_whitespace:
from html5lib.filters.whitespace import Filter
from ..filters.whitespace import Filter
treewalker = Filter(treewalker)
if self.sanitize:
from html5lib.filters.sanitizer import Filter
from ..filters.sanitizer import Filter
treewalker = Filter(treewalker)
if self.omit_optional_tags:
from html5lib.filters.optionaltags import Filter
from ..filters.optionaltags import Filter
treewalker = Filter(treewalker)
for token in treewalker:
type = token["type"]
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treebuilders/_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import, division, unicode_literals
from six import text_type

from html5lib.constants import scopingElements, tableInsertModeElements, namespaces
from ..constants import scopingElements, tableInsertModeElements, namespaces

# The scope markers are inserted when entering object elements,
# marquees, table cells, and table captions, and are used to prevent formatting
Expand Down
6 changes: 3 additions & 3 deletions html5lib/treebuilders/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import weakref

from . import _base
from html5lib import constants
from html5lib.constants import namespaces
from html5lib.utils import moduleFactoryFactory
from .. import constants
from ..constants import namespaces
from ..utils import moduleFactoryFactory


def getDomBuilder(DomImplementation):
Expand Down
8 changes: 4 additions & 4 deletions html5lib/treebuilders/etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import re

from . import _base
from html5lib import ihatexml
from html5lib import constants
from html5lib.constants import namespaces
from html5lib.utils import moduleFactoryFactory
from .. import ihatexml
from .. import constants
from ..constants import namespaces
from ..utils import moduleFactoryFactory

tag_regexp = re.compile("{([^}]*)}(.*)")

Expand Down
12 changes: 5 additions & 7 deletions html5lib/treebuilders/etree_lxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
import sys

from . import _base
from html5lib.constants import DataLossWarning
import html5lib.constants as constants
from ..constants import DataLossWarning
from .. import constants
from . import etree as etree_builders
from html5lib import ihatexml
from .. import ihatexml

import lxml.etree as etree

try:
import lxml.etree as etree
except ImportError:
pass

fullTree = True
tag_regexp = re.compile("{([^}]*)}(.*)")
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treebuilders/simpletree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from six import text_type

from . import _base
from html5lib.constants import voidElements, namespaces, prefixes
from ..constants import voidElements, namespaces, prefixes
from xml.sax.saxutils import escape

# Really crappy basic implementation of a DOM-core like thing
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treewalkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def getTreeWalker(treeType, implementation=None, **kwargs):
treeType = treeType.lower()
if treeType not in treeWalkerCache:
if treeType in ("dom", "pulldom", "simpletree"):
name = "html5lib.treewalkers." + treeType
name = "%s.%s" % (__name__, treeType)
__import__(name)
mod = sys.modules[name]
treeWalkerCache[treeType] = mod.TreeWalker
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treewalkers/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gettext
_ = gettext.gettext

from html5lib.constants import voidElements, spaceCharacters
from ..constants import voidElements, spaceCharacters
spaceCharacters = "".join(spaceCharacters)


Expand Down
2 changes: 1 addition & 1 deletion html5lib/treewalkers/genshistream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import _base

from html5lib.constants import voidElements, namespaces
from ..constants import voidElements, namespaces


class TreeWalker(_base.TreeWalker):
Expand Down
4 changes: 2 additions & 2 deletions html5lib/treewalkers/lxmletree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from six import text_type

from lxml import etree
from html5lib.treebuilders.etree import tag_regexp
from ..treebuilders.etree import tag_regexp

from gettext import gettext
_ = gettext

from . import _base

from html5lib import ihatexml
from .. import ihatexml


def ensure_str(s):
Expand Down
2 changes: 1 addition & 1 deletion html5lib/treewalkers/pulldom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from . import _base

from html5lib.constants import voidElements
from ..constants import voidElements


class TreeWalker(_base.TreeWalker):
Expand Down