@@ -24,6 +24,7 @@ from __future__ import unicode_literals | |||||
from ...compat import str | from ...compat import str | ||||
from ...string_mixin import StringMixIn | from ...string_mixin import StringMixIn | ||||
from ...utils import parse_anything | |||||
__all__ = ["Attribute"] | __all__ = ["Attribute"] | ||||
@@ -62,3 +63,15 @@ class Attribute(StringMixIn): | |||||
def quoted(self): | def quoted(self): | ||||
"""Whether the attribute's value is quoted with double quotes.""" | """Whether the attribute's value is quoted with double quotes.""" | ||||
return self._quoted | return self._quoted | ||||
@name.setter | |||||
def name(self, newval): | |||||
self._name = parse_anything(newval) | |||||
@value.setter | |||||
def value(self, newval): | |||||
self._value = parse_anything(newval) | |||||
@quoted.setter | |||||
def quoted(self, newval): | |||||
self._quoted = bool(newval) |
@@ -73,4 +73,4 @@ class Parameter(StringMixIn): | |||||
@showkey.setter | @showkey.setter | ||||
def showkey(self, newval): | def showkey(self, newval): | ||||
self._showkey = newval | |||||
self._showkey = bool(newval) |
@@ -24,6 +24,7 @@ from __future__ import unicode_literals | |||||
from . import Node | from . import Node | ||||
from ..compat import str | from ..compat import str | ||||
from ...utils import parse_anything | |||||
__all__ = ["Heading"] | __all__ = ["Heading"] | ||||
@@ -60,3 +61,14 @@ class Heading(Node): | |||||
def level(self): | def level(self): | ||||
"""The heading level, as an integer between 1 and 6, inclusive.""" | """The heading level, as an integer between 1 and 6, inclusive.""" | ||||
return self._level | return self._level | ||||
@title.setter | |||||
def title(self, value): | |||||
self._title = parse_anything(value) | |||||
@level.setter | |||||
def level(self, value): | |||||
value = int(value) | |||||
if value < 1 or value > 6: | |||||
raise ValueError(value) | |||||
self._level = value |
@@ -23,7 +23,7 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
from . import Node | from . import Node | ||||
from ..compat import htmlentities | |||||
from ..compat import htmlentities, str | |||||
__all__ = ["HTMLEntity"] | __all__ = ["HTMLEntity"] | ||||
@@ -116,6 +116,27 @@ class HTMLEntity(Node): | |||||
""" | """ | ||||
return self._hex_char | return self._hex_char | ||||
@value.setter | |||||
def value(self, newval): | |||||
newval = str(newval) | |||||
if newval not in htmlentities.entitydefs: | |||||
test = int(self.value, 16) | |||||
if test < 0 or (test > 0x10FFFF and int(self.value) > 0x10FFFF): | |||||
raise ValueError(newval) | |||||
self._value = newval | |||||
@named.setter | |||||
def named(self, newval): | |||||
self._named = bool(newval) | |||||
@hexadecimal.setter | |||||
def hexadecimal(self, newval): | |||||
self._hexadecimal = bool(newval) | |||||
@hex_char.setter | |||||
def hex_char(self, newval): | |||||
self._hex_char = bool(newval) | |||||
def normalize(self): | def normalize(self): | ||||
"""Return the unicode character represented by the HTML entity.""" | """Return the unicode character represented by the HTML entity.""" | ||||
if self.named: | if self.named: | ||||
@@ -24,6 +24,7 @@ from __future__ import unicode_literals | |||||
from . import Node, Text | from . import Node, Text | ||||
from ..compat import str | from ..compat import str | ||||
from ..utils import parse_anything | |||||
__all__ = ["Tag"] | __all__ = ["Tag"] | ||||
@@ -207,3 +208,34 @@ class Tag(Node): | |||||
def close_padding(self): | def close_padding(self): | ||||
"""How much spacing to insert before the last closing >.""" | """How much spacing to insert before the last closing >.""" | ||||
return self._close_padding | return self._close_padding | ||||
@type.setter | |||||
def type(self, value): | |||||
value = int(value) | |||||
if value not in self.TAGS_INVISIBLE | self.TAGS_VISIBLE: | |||||
raise ValueError(value) | |||||
self._type = value | |||||
@tag.setter | |||||
def tag(self, value): | |||||
self._tag = parse_anything(value) | |||||
@contents.setter | |||||
def contents(self, value): | |||||
self._contents = parse_anything(value) | |||||
@showtag.setter | |||||
def showtag(self, value): | |||||
self._showtag = bool(value) | |||||
@self_closing.setter | |||||
def self_closing(self, value): | |||||
self._self_closing = bool(value) | |||||
@open_padding.setter | |||||
def open_padding(self, value): | |||||
self._open_padding = int(value) | |||||
@close_padding.setter | |||||
def close_padding(self, value): | |||||
self._close_padding = int(value) |