| @@ -28,6 +28,8 @@ from ..compat import str | |||||
| __all__ = ["Tag"] | __all__ = ["Tag"] | ||||
| class Tag(Node): | class Tag(Node): | ||||
| """Represents an HTML-style tag in wikicode, like ``<ref>``.""" | |||||
| TAG_UNKNOWN = 0 | TAG_UNKNOWN = 0 | ||||
| # Basic HTML: | # Basic HTML: | ||||
| @@ -146,6 +148,12 @@ class Tag(Node): | |||||
| write(">") | write(">") | ||||
| def _translate(self): | def _translate(self): | ||||
| """If the HTML-style tag has a wikicode representation, return that. | |||||
| For example, ``<b>Foo</b>`` can be represented as ``'''Foo'''``. This | |||||
| returns a tuple of the character starting the sequence and the | |||||
| character ending it. | |||||
| """ | |||||
| translations = { | translations = { | ||||
| self.TAG_ITALIC: ("''", "''"), | self.TAG_ITALIC: ("''", "''"), | ||||
| self.TAG_BOLD: ("'''", "'''"), | self.TAG_BOLD: ("'''", "'''"), | ||||
| @@ -159,32 +167,44 @@ class Tag(Node): | |||||
| @property | @property | ||||
| def type(self): | def type(self): | ||||
| """The tag type.""" | |||||
| return self._type | return self._type | ||||
| @property | @property | ||||
| def tag(self): | def tag(self): | ||||
| """The tag itself, as a ``Wikicode`` object.""" | |||||
| return self._tag | return self._tag | ||||
| @property | @property | ||||
| def contents(self): | def contents(self): | ||||
| """The contents of the tag, as a ``Wikicode`` object.""" | |||||
| return self._contents | return self._contents | ||||
| @property | @property | ||||
| def attrs(self): | def attrs(self): | ||||
| """The list of attributes affecting the tag. | |||||
| Each attribute is an instance of | |||||
| :py:class:`~mwparserfromhell.nodes.extas.attribute.Attribute`. | |||||
| """ | |||||
| return self._attrs | return self._attrs | ||||
| @property | @property | ||||
| def showtag(self): | def showtag(self): | ||||
| """Whether to show the tag itself instead of a wikicode version.""" | |||||
| return self._showtag | return self._showtag | ||||
| @property | @property | ||||
| def self_closing(self): | def self_closing(self): | ||||
| """Whether the tag is self-closing with no content.""" | |||||
| return self._self_closing | return self._self_closing | ||||
| @property | @property | ||||
| def open_padding(self): | def open_padding(self): | ||||
| """How much spacing to insert before the first closing >.""" | |||||
| return self._open_padding | return self._open_padding | ||||
| @property | @property | ||||
| def close_padding(self): | def close_padding(self): | ||||
| """How much spacing to insert before the last closing >.""" | |||||
| return self._close_padding | return self._close_padding | ||||