The elements.html classes
The purpose of this module is to provide classes corresponding to
most elements (except <style>, <script> and similar
non-document content elements) and core attributes (except @style
and the %events attributes) of HTML4.01 and HTML5. It is not
totally compliant with the HTML4.01 and HTML5 standards, but is enough
to model most real-world HTML. It contains no provisions to ensure
that elements of a particular kind only contain allowed
sub-elements.
-
ferenda.elements.html.elements_from_soup(soup, remove_tags=('script', 'style', 'font', 'map', 'center'), keep_attributes=('class', 'id', 'dir', 'lang', 'src', 'href', 'name', 'alt'))[source]
Converts a BeautifulSoup tree into a tree of
ferenda.elements.html.HTMLElement objects. Some
non-semantic attributes and tags are removed in the process.
| Parameters: |
- soup – Soup object to convert
- remove_tags (list) – Tags that should not be included
- keep_attributes (list) – Attributes to keep
|
| Returns: | tree of element objects
|
| Return type: | ferenda.elements.html.HTMLElement
|
-
class
ferenda.elements.html.HTMLElement(*args, **kwargs)[source]
Abstract base class for all elements.
-
class
ferenda.elements.html.HTML(*args, **kwargs)[source]
Element corresponding to the <html> tag
-
class
ferenda.elements.html.Head(*args, **kwargs)[source]
Element corresponding to the <head> tag
-
class
ferenda.elements.html.Title(*args, **kwargs)[source]
Element corresponding to the <title> tag
-
class
ferenda.elements.html.Body(*args, **kwargs)[source]
Element corresponding to the <body> tag
-
as_xhtml(uri, parent_uri=None)[source]
Converts this object to a lxml.etree object (with children)
| Parameters: | uri (str) – If provided, gets converted to an @about attribute
in the resulting XHTML. |
-
class
ferenda.elements.html.P(*args, **kwargs)[source]
Element corresponding to the <p> tag
-
class
ferenda.elements.html.H1(*args, **kwargs)[source]
Element corresponding to the <h1> tag
-
class
ferenda.elements.html.H2(*args, **kwargs)[source]
Element corresponding to the <h2> tag
-
class
ferenda.elements.html.H3(*args, **kwargs)[source]
Element corresponding to the <h3> tag
-
class
ferenda.elements.html.H4(*args, **kwargs)[source]
Element corresponding to the <h4> tag
-
class
ferenda.elements.html.H5(*args, **kwargs)[source]
Element corresponding to the <h5> tag
-
class
ferenda.elements.html.H6(*args, **kwargs)[source]
Element corresponding to the <h6> tag
-
class
ferenda.elements.html.UL(*args, **kwargs)[source]
Element corresponding to the <ul> tag
-
class
ferenda.elements.html.OL(*args, **kwargs)[source]
Element corresponding to the <ol> tag
-
class
ferenda.elements.html.LI(*args, **kwargs)[source]
Element corresponding to the <li> tag
-
class
ferenda.elements.html.Pre(*args, **kwargs)[source]
Element corresponding to the <pre> tag
-
class
ferenda.elements.html.DL(*args, **kwargs)[source]
Element corresponding to the <dl> tag
-
class
ferenda.elements.html.DT(*args, **kwargs)[source]
Element corresponding to the <dt> tag
-
class
ferenda.elements.html.DD(*args, **kwargs)[source]
Element corresponding to the <dd> tag
-
class
ferenda.elements.html.Div(*args, **kwargs)[source]
Element corresponding to the <div> tag
-
class
ferenda.elements.html.Blockquote(*args, **kwargs)[source]
Element corresponding to the <blockquote> tag
-
class
ferenda.elements.html.Form(*args, **kwargs)[source]
Element corresponding to the <form> tag
-
class
ferenda.elements.html.HR(*args, **kwargs)[source]
Element corresponding to the <hr> tag
-
class
ferenda.elements.html.Table(*args, **kwargs)[source]
Element corresponding to the <table> tag
-
class
ferenda.elements.html.Fieldset(*args, **kwargs)[source]
Element corresponding to the <fieldset> tag
-
class
ferenda.elements.html.Address(*args, **kwargs)[source]
Element corresponding to the <address> tag
-
class
ferenda.elements.html.TT(*args, **kwargs)[source]
Element corresponding to the <tt > tag
-
class
ferenda.elements.html.I(*args, **kwargs)[source]
Element corresponding to the <i > tag
-
class
ferenda.elements.html.B(*args, **kwargs)[source]
Element corresponding to the <b > tag
-
class
ferenda.elements.html.U(*args, **kwargs)[source]
Element corresponding to the <u > tag
-
class
ferenda.elements.html.Big(*args, **kwargs)[source]
Element corresponding to the <big > tag
-
class
ferenda.elements.html.Small(*args, **kwargs)[source]
Element corresponding to the <small> tag
-
class
ferenda.elements.html.Em(*args, **kwargs)[source]
Element corresponding to the <em > tag
-
class
ferenda.elements.html.Strong(*args, **kwargs)[source]
Element corresponding to the <strong > tag
-
class
ferenda.elements.html.Dfn(*args, **kwargs)[source]
Element corresponding to the <dfn > tag
-
class
ferenda.elements.html.Code(*args, **kwargs)[source]
Element corresponding to the <code > tag
-
class
ferenda.elements.html.Samp(*args, **kwargs)[source]
Element corresponding to the <samp > tag
-
class
ferenda.elements.html.Kbd(*args, **kwargs)[source]
Element corresponding to the <kbd > tag
-
class
ferenda.elements.html.Var(*args, **kwargs)[source]
Element corresponding to the <var > tag
-
class
ferenda.elements.html.Cite(*args, **kwargs)[source]
Element corresponding to the <cite > tag
-
class
ferenda.elements.html.Abbr(*args, **kwargs)[source]
Element corresponding to the <abbr > tag
-
class
ferenda.elements.html.Acronym(*args, **kwargs)[source]
Element corresponding to the <acronym> tag
-
class
ferenda.elements.html.A(*args, **kwargs)[source]
Element corresponding to the <a > tag
-
class
ferenda.elements.html.Img(*args, **kwargs)[source]
Element corresponding to the <img > tag
-
class
ferenda.elements.html.Object(*args, **kwargs)[source]
Element corresponding to the <object > tag
-
class
ferenda.elements.html.Br(*args, **kwargs)[source]
Element corresponding to the <br > tag
-
class
ferenda.elements.html.Q(*args, **kwargs)[source]
Element corresponding to the <q > tag
-
class
ferenda.elements.html.Sub(*args, **kwargs)[source]
Element corresponding to the <sub > tag
-
class
ferenda.elements.html.Sup(*args, **kwargs)[source]
Element corresponding to the <sup > tag
-
class
ferenda.elements.html.Span(*args, **kwargs)[source]
Element corresponding to the <span > tag
-
class
ferenda.elements.html.BDO(*args, **kwargs)[source]
Element corresponding to the <bdo> tag
-
class
ferenda.elements.html.Input(*args, **kwargs)[source]
Element corresponding to the <input> tag
-
class
ferenda.elements.html.Select(*args, **kwargs)[source]
Element corresponding to the <select> tag
-
class
ferenda.elements.html.Textarea(*args, **kwargs)[source]
Element corresponding to the <textarea> tag
-
class
ferenda.elements.html.Label(*args, **kwargs)[source]
Element corresponding to the <label> tag
-
class
ferenda.elements.html.Button(*args, **kwargs)[source]
Element corresponding to the <button> tag
-
class
ferenda.elements.html.Caption(*args, **kwargs)[source]
Element corresponding to the <caption> tag
-
class
ferenda.elements.html.Thead(*args, **kwargs)[source]
Element corresponding to the <thead> tag
Element corresponding to the <tfoot> tag
-
class
ferenda.elements.html.Tbody(*args, **kwargs)[source]
Element corresponding to the <tbody> tag
-
class
ferenda.elements.html.Colgroup(*args, **kwargs)[source]
Element corresponding to the <colgroup> tag
-
class
ferenda.elements.html.Col(*args, **kwargs)[source]
Element corresponding to the <col> tag
-
class
ferenda.elements.html.TR(*args, **kwargs)[source]
Element corresponding to the <tr> tag
-
class
ferenda.elements.html.TH(*args, **kwargs)[source]
Element corresponding to the <th> tag
-
class
ferenda.elements.html.TD(*args, **kwargs)[source]
Element corresponding to the <td> tag
-
class
ferenda.elements.html.Ins(*args, **kwargs)[source]
Element corresponding to the <ins> tag
-
class
ferenda.elements.html.Del(*args, **kwargs)[source]
Element corresponding to the <del> tag
-
class
ferenda.elements.html.HTML5Element(*args, **kwargs)[source]
-
tagname = 'div'
-
classname
-
class
ferenda.elements.html.Article(*args, **kwargs)[source]
Element corresponding to the <article> tag
-
class
ferenda.elements.html.Aside(*args, **kwargs)[source]
Element corresponding to the <aside> tag
-
class
ferenda.elements.html.Bdi(*args, **kwargs)[source]
Element corresponding to the <bdi> tag
-
class
ferenda.elements.html.Details(*args, **kwargs)[source]
Element corresponding to the <details> tag
-
class
ferenda.elements.html.Dialog(*args, **kwargs)[source]
Element corresponding to the <dialog> tag
-
class
ferenda.elements.html.Summary(*args, **kwargs)[source]
Element corresponding to the <summary> tag
-
class
ferenda.elements.html.Figure(*args, **kwargs)[source]
Element corresponding to the <figure> tag
-
class
ferenda.elements.html.Figcaption(*args, **kwargs)[source]
Element corresponding to the <figcaption> tag
Element corresponding to the <footer> tag
Element corresponding to the <header> tag
-
class
ferenda.elements.html.Hgroup(*args, **kwargs)[source]
Element corresponding to the <hgroup> tag
-
class
ferenda.elements.html.Mark(*args, **kwargs)[source]
Element corresponding to the <mark> tag
-
class
ferenda.elements.html.Meter(*args, **kwargs)[source]
Element corresponding to the <meter> tag
-
class
ferenda.elements.html.Nav(*args, **kwargs)[source]
Element corresponding to the <nav> tag
-
class
ferenda.elements.html.Progress(*args, **kwargs)[source]
Element corresponding to the <progress> tag
-
class
ferenda.elements.html.Ruby(*args, **kwargs)[source]
Element corresponding to the <ruby> tag
-
class
ferenda.elements.html.Rt(*args, **kwargs)[source]
Element corresponding to the <rt> tag
-
class
ferenda.elements.html.Rp(*args, **kwargs)[source]
Element corresponding to the <rp> tag
-
class
ferenda.elements.html.Section(*args, **kwargs)[source]
Element corresponding to the <section> tag
-
class
ferenda.elements.html.Time(*args, **kwargs)[source]
Element corresponding to the <time> tag
-
class
ferenda.elements.html.Wbr(*args, **kwargs)[source]
Element corresponding to the <wbr> tag