API Reference¶
Class for constructing anchor tag.
Parameters: - charset (str) – Specifies the character-set of a linked document.
- coords (mixed) – A list/tuple/string of coordinate values.
- download (str) – Specifies that the target will be downloaded when a user clicks on the hyper link.
- href (str) – Specifies the URL of the page the link goes to.
- hreflang (str) – Specifies the language of the linked document.
- name (str) – Specifies the name of an anchor.
- rel (str) – Specifies the relationship between the current document and the linked document.
- rev (str) – Specifies the relationship between the linked document and the current document.
- shape (str) – Specifies the shape of a link.
- target (str) – Specifies where to open the linked document.
- type (str) – Specifies the media type of the linked document.
- text (str) – Anchor tag text. (Ex. <a>text</a>)
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Changed in version 0.3.1: Added URL validation for href attribute.
Changed in version 0.4.3-dev: Now the user can be displayed with warnings for charset attribute. Used custom exceptions for all the attributes. Removed the method
validate_values()
.Returns the constructed anchor tag <a></a>.
Returns coordinates after a series of validations.
Parameters: - shape (str) – Shape of a link (Ex. rect/circle/poly/etc.)
- coords (mixed) – A list/tuple/str of coordinate values.
Returns: A string of coordinate values.
Return type: str
Validates whether an attribute is dependant on another attribute or not. Some of the attributes requires href attribute to be set.
Validates charset attribute. Warn the user showing the common character sets used.
Class for constructing abbr tag.
Parameters: text (str) – Abbr tag text. (Ex. <abbr>text</abbr>) New in version 0.1.0.
Changed in version 0.2.0: Renamed
construct_tag()
toconstruct()
.Returns the constructed abbr tag <abbr></abbr>.
Class for constructing acronym tag.
Parameters: text (str) – Acronym tag text. (Ex. <acronym>text</acronym>) New in version 0.1.0.
Changed in version 0.2.0: Renamed
construct_tag()
toconstruct()
.Returns the constructed acronym tag <acronym></acronym>.
Class for constructing address tag.
Parameters: text (str) – Address tag text. (Ex. <address>text</address>) New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed address tag <address></address>.
Class for constructing area tag.
Parameters: - alt (str) – Specifies an alternate text for the area. Required if the href attribute is present.
- coords (mixed) – Specifies the coordinates of the area.
- download (str) – Specifies that the target will be downloaded when a user clicks on the hyper link.
- href (str) – Specifies the hyperlink target for the area.
- hreflang (str) – Specifies the language of the target URL.
- media (str) – Specifies what media/device the target URL is optimized for.
- nohref (bool) – Specifies that an area has no associated link.
- rel (str) – Specifies the relationship between the current document and the target URL.
- shape (str) – Specifies the shape of the area.
- target (str) – Specifies where to open the target URL.
- type (str) – Specifies the media type of the target URL.
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Changed in version 0.3.1: Added URL validation for href attribute.
Returns the constructed area tag <area></area>.
Returns coordinates after a series of validations.
Parameters: - shape (str) – Shape of a link (Ex. rect/circle/poly/etc.)
- coords (mixed) – A list/tuple/str of coordinate values.
Returns: A string of coordinate values.
Return type: str
Validates whether an attribute is dependant on another attribute or not. Some of the attributes requires href attribute to be set.
Validates area’s alt attribute.
Validates whether the given attribute value is a valid value or not. Some of the attributes have confined values. Even if we give some other value, the html output would not be correct.
Class for constructing article tag.
Parameters: text (str) – Article tag text. (Ex. <article>text</article>) New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed article tag <article></article>.
Class for constructing bold tag.
Parameters: text (str) – Bold tag text. (Ex. <b>text</b>) New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed bold tag <b></b>.
Class for constructing base tag.
Parameters: - href (str) – Specifies the base URL for all relative URLs in the page.
- target (str) – Specifies the default target for all hyperlinks and forms in the page.
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Changed in version 0.3.1: Added URL validation for href attribute.
Returns the constructed base tag <base>.
Validates the following: - Either of href or target attribute value is given. - Check whether both href and target attribute values are strings or not.
Class for constructing button tag.
Parameters: - autofocus (bool) – Specifies that a button should automatically get focus when the page loads.
- disabled (bool) – Specifies that a button should be disabled.
- form (str) – Specifies one or more forms the button belongs to.
- formaction (str) – Specifies where to send the form-data when a form is submitted. Only for type=”submit”.
- formenctype (str) – Specifies how form-data should be encoded before sending it to a server. Only for type=”submit”.
- formmethod (str) – Specifies how to send the form-data (which HTTP method to use). Only for type=”submit”.
- formnovalidate (bool) – Specifies that the form-data should not be validated on submission. Only for type=”submit”.
- formtarget (str) – Specifies where to display the response after submitting the form. Only for type=”submit”.
- name (str) – Specifies a name for the button.
- type (str) – Specifies the type of button.
- value (str) – Specifies an initial value for the button.
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Changed in version 0.4.3-dev: Removed
validate_values()
method.Returns the constructed base tag <button>.
Validates whether an attribute is dependant on another attribute or not. Some of the attributes requires type attribute to be set to ‘submit’.
Validate the type attribute for a <button> element. Different browsers use different default types for the <button> element.
Class for constructing canvas tag.
Parameters: - height (str) – Specifies the height of the canvas.
- width (str) – Specifies the width of the canvas.
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed canvas tag <canvas>.
Class for constructing caption tag.
Parameters: - align (str) – Defines the alignment of the caption.
- text (str) – Specifies the caption text.
New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed caption tag <caption>.
Class for constructing cite tag.
Parameters: text (str) – Specifies the citation text. New in version 0.1.0.
Changed in version 0.2.0: Renamed the method construct_tag to construct.
Returns the constructed cite tag <cite>.
Class for constructing col tag.
Parameters: - align (str) – Specifies the alignment of the content related to a <col> element.
- char (str) – Specifies the alignment of the content related to a <col> element to a character.
- charoff (int) – Specifies the number of characters the content will be aligned from the character specified by the char attribute.
- span (int) – Specifies the number of columns a <col> element should span.
- valign (str) – Specifies the vertical alignment of the content related to a <col> element.
- width (str) – Specifies the width of a <col> element.
New in version 0.2.0.
Returns the constructed col tag <col>.
Validates char attribute. The char attribute can only be used if the align attribute is set to “char”.
Validates charoff attribute. The charoff attribute can only be used if the char attribute is specified and the align attribute is set to “char”.
Class for constructing colgroup tag.
Parameters: - align (str) – Aligns the content in a column group.
- char (str) – Aligns the content in a column group to a character.
- charoff (int) – Sets the number of characters the content will be aligned from the character specified by the char attribute.
- span (int) – Specifies the number of columns a column group should span.
- valign (str) – Vertical aligns the content in a column group.
- width (str) – Specifies the width of a column group.
New in version 0.2.0.
Returns the constructed colgroup tag <colgroup>.
Validates char attribute. The char attribute can only be used if the align attribute is set to “char”.
Validates charoff attribute. The charoff attribute can only be used if the char attribute is specified and the align attribute is set to “char”.
Class for constructing dd tag.
Parameters: text (str) – Specifies the dd text. (As in <dd>{text}</dd>) New in version 0.2.0.
Returns the constructed dd tag <dd></dd>.
Class for constructing del tag.
Parameters: - cite (str) – Specifies a URL to a document that explains the reason why the text was deleted.
- datetime (datetime) – Specifies the date and time of when the text was deleted.
New in version 0.2.0.
Returns the constructed del tag <del>.
Class for constructing details tag.
Parameters: - open (bool) – Specifies that the details should be visible (open) to the user.
- text (str) – Specifies the details text. (As in <details>{text}</details>)
New in version 0.2.0.
Returns the constructed details tag <details></details>.
Class for constructing dialog tag.
Parameters: - open (bool) – Specifies that the dialog element is active and that the user can interact with it.
- text (str) – Specifies the dialog text. (As in <dialog>{text}</dialog>)
New in version 0.2.0.
Returns the constructed dialog tag <dialog></dialog>.
Class for constructing div tag.
Parameters: - align (str) – Specifies the alignment of the content inside a <div> element.
- text (str) – Specifies the div text. (As in <div>{text}</div>)
New in version 0.2.0.
Returns the constructed div tag <div></div>.
Class for constructing dl tag.
Parameters: text (str) – Specifies the dl text. (As in <dl>{text}</dl>) New in version 0.2.0.
Returns the constructed dl tag <dl></dl>.
Class for constructing dt tag.
Parameters: text (str) – Specifies the dt text. (As in <dt>{text}</dt>) New in version 0.2.0.
Returns the constructed dt tag <dt></dt>.
Class for constructing embed tag.
Parameters: - height (str) – Specifies the height of the embedded content (in pixels).
- width (str) – Specifies the width of the embedded content (in pixels).
- src (str) – Specifies the address of the external file to embed.
- type (str) – Specifies the media type of the embedded content.
New in version 0.2.0.
Returns the constructed embed tag <embed>.
Class for constructing fieldset tag.
Parameters: - disabled (bool) – Specifies that a group of related form elements should be disabled.
- form (str) – Specifies one or more forms the fieldset belongs to.
- name (str) – Specifies a name for the fieldset.
New in version 0.2.0.
Returns the constructed fieldset tag <fieldset></fieldset>.
Class for constructing figure tag.
Parameters: text (str) – Specifies the figure text. (As in <figure>{text}</figure>) New in version 0.2.0.
Returns the constructed figure tag <figure></figure>.
Class for constructing the footer tag.
Parameters: text (str) – Specifies the footer text. (As in <footer>{text}</footer>) New in version 0.2.0.
Returns the constructed footer tag <footer></footer>.
Class for constructing <form> tag.
Parameters: - accept (str) – Specifies a comma-separated list of file types that the server accepts (that can be submitted through the file upload).
- action (str) – Specifies where to send the form-data when a form is submitted.
- autocomplete (str) – Specifies whether a form should have autocomplete on or off.
- enctype (str) – Specifies how the form-data should be encoded when submitting it to the server (only for method=”post”).
- method (str) – Specifies the HTTP method to use when sending form-data.
- name (str) – Specifies the name of a form.
- novalidate (bool) – Specifies that the form should not be validated when submitted.
- target (str) – Specifies where to display the response that is received after submitting the form.
- text (str) – Specifies the form text. (As in <form>{text}</form>)
New in version 0.2.0.
Returns the constructed form tag <form></form>.
Validates enctype attribute. The enctype attribute can be used only if method is post.
Class for constructing <frame> tag.
Parameters: - frameborder (str) – Specifies whether or not to display a border around a frame.
- longdesc (str) – Specifies a page that contains a long description of the content of a frame.
- marginheight (str) – Specifies the top and bottom margins of a frame.
- marginwidth (str) – Specifies the left and right margins of a frame.
- name (str) – Specifies the name of a frame.
- noresize (str) – Specifies that a frame is not resizable.
- scrolling (str) – Specifies whether or not to display scrollbars in a frame.
- src (str) – Specifies the URL of the document to show in a frame.
New in version 0.2.0.
Changed in version 0.3.1: Added URL validation for src attribute.
Returns the constructed tag <frame>.
Class for constructing <frameset> tag.
Parameters: - cols (str) – Specifies the number and size of columns in a frameset.
- rows (str) – Specifies the number and size of rows in a frameset.
New in version 0.2.0.
Returns the constructed tag <frameset>.
Class for constructing <h1> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h1> text. (As in <h1>{text}</h1>)
New in version 0.3.0.
Returns the constructed tag <h1>.
Class for constructing <h2> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h2> text. (As in <h2>{text}</h2>)
New in version 0.3.0.
Returns the constructed tag <h2>.
Class for constructing <h3> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h3> text. (As in <h3>{text}</h3>)
New in version 0.3.0.
Returns the constructed tag <h3>.
Class for constructing <h4> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h4> text. (As in <h4>{text}</h4>)
New in version 0.3.0.
Returns the constructed tag <h4>.
Class for constructing <h5> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h5> text. (As in <h5>{text}</h5>)
New in version 0.3.0.
Returns the constructed tag <h5>.
Class for constructing <h6> tag.
Parameters: - align (str) – Specifies the alignment of a heading.
- text (str) – Specifies the <h6> text. (As in <h6>{text}</h6>)
New in version 0.3.0.
Returns the constructed tag <h6>.
Class for constructing <head> tag.
Parameters: text (str) – Specifies the head text. (As in <head>{text}</head>) New in version 0.3.0.
Returns the constructed tag <head>.
Class for constructing the header tag.
Parameters: text (str) – Specifies the header text. (As in <header>{text}</header>) New in version 0.3.0.
Returns the constructed header tag <header></header>.
Class for constructing hr tag.
Parameters: - align (str) – Specifies the alignment of a <hr> element.
- noshade (bool) – Specifies that a <hr> element should render in one solid color (noshaded), instead of a shaded color.
- size (str) – Specifies the height of a <hr> element.
- width (str) – Specifies the width of a <hr> element
New in version 0.3.0.
Returns the constructed hr tag <hr>.
Class for constructing html tag.
Parameters: - manifest (str) – Specifies the address of the document’s cache manifest (for offline browsing)
- xmlns (str) – Specifies the XML namespace attribute (If you need your content to conform to XHTML)
- text (str) – Specifies the html text. (As in <html>{text}</html>)
New in version 0.4.0.
Returns the constructed html tag <html>.
Class for constructing <i> tag.
Parameters: text (str) – Specifies the italics text. (As in <i>{text}</i>) New in version 0.4.0.
Returns the constructed italics tag <i>.
Class for constructing <iframe> tag.
Parameters: - align (str) – Specifies the alignment of an <iframe> according to surrounding elements.
- frameborder (str) – Specifies whether or not to display a border around an <iframe>.
- height (str) – Specifies the height of an <iframe>.
- longdesc (str) – Specifies a page that contains a long description of the content of an <iframe>.
- marginheight (str) – Specifies the top and bottom margins of the content of an <iframe>.
- marginwidth (str) – Specifies the left and right margins of the content of an <iframe>.
- name (str) – Specifies the name of an <iframe>.
- sandbox (str) – Enables an extra set of restrictions for the content in an <iframe>.
- scrolling (str) – Specifies whether or not to display scrollbars in an <iframe>.
- src (str) – Specifies the address of the document to embed in the <iframe>.
- srcdoc (str) – Specifies the HTML content of the page to show in the <iframe>.
- width (str) – Specifies the width of an <iframe>.
New in version 0.4.0.
Returns the constructed iframe tag <iframe>.
Validates sandbox attribute. The value of the sandbox attribute can either be just sandbox (then all restrictions are applied), or a space-separated list of pre-defined values that will REMOVE the particular restrictions.
Class for constructing <img> tag.
Parameters: - align (str) – Specifies the alignment of an image according to surrounding elements.
- alt (str) – Specifies an alternate text for an image.
- border (str) – Specifies the width of the border around an image.
- crossorigin (str) – Allow images from third-party sites that allow cross-origin access to be used with canvas.
- height (str) – Specifies the height of an image.
- hspace (str) – Specifies the whitespace on left and right side of an image.
- ismap (bool) – Specifies an image as a server-side image-map.
- longdesc (str) – Specifies a URL to a detailed description of an image.
- src (str) – Specifies the URL of an image.
- usemap (str) – Specifies an image as a client-side image-map.
- vspace (str) – Specifies the whitespace on top and bottom of an image.
- width (str) – Specifies the width of an image.
New in version 0.4.0.
Returns the constructed image tag <img>.
Class for constructing <input> tag.
Parameters: - accept (str) – Specifies the types of files that the server accepts (only for type=”file”).
- align (str) – Specifies the alignment of an image input (only for type=”image”).
- alt (str) – Specifies an alternate text for images (only for type= “image”).
- autocomplete (str) – Specifies whether an <input> element should have autocomplete enabled.
- autofocus (bool) – Specifies that an <input> element should automatically get focus when the page loads.
- checked (bool) – Specifies that an <input> element should be pre-selected when the page loads (for type=”checkbox” or type=”radio”).
- dirname (str) – Specifies that the text direction will be submitted.
- disabled (bool) – Specifies that an <input> element should be disabled.
- form (str) – Specifies one or more forms the <input> element belongs to.
- formaction (str) – Specifies the URL of the file that will process the input control when the form is submitted (for type=”submit” and type=”image”).
- formenctype (str) – Specifies how the form-data should be encoded when submitting it to the server (for type=”submit” and type=”image”).
- formmethod (str) – Defines the HTTP method for sending data to the action URL (for type=”submit” and type=”image”).
- formnovalidate (bool) – Defines that form elements should not be validated when submitted.
- formtarget (str) – Specifies where to display the response that is received after submitting the form (for type=”submit” and type=”image”).
- height (int/float) – Specifies the height of an <input> element (only for type=”image”).
- list (str) – Refers to a <datalist> element that contains pre-defined options for an <input> element.
- max (int/date/time) – Specifies the maximum value for an <input> element.
- maxlength (int) – Specifies the maximum number of characters allowed in an <input> element.
- min (int/date/time) – Specifies a minimum value for an <input> element.
- multiple (bool) – Specifies that a user can enter more than one value in an <input> element.
- name (str) – Specifies the name of an <input> element.
- pattern (str) – Specifies a regular expression that an <input> element’s value is checked against.
- placeholder (str) – Specifies a short hint that describes the expected value of an <input> element.
- readonly (bool) – Specifies that an input field is read-only.
- required (bool) – Specifies that an input field must be filled out before submitting the form.
- size (int) – Specifies the width, in characters, of an <input> element.
- src (str) – Specifies the URL of the image to use as a submit button (only for type=”image”).
- step (int) – Specifies the legal number intervals for an input field.
- type (str) – Specifies the type <input> element to display.
- value (str) – Specifies the value of an <input> element.
- width (int/float) – Specifies the width of an <input> element (only for type=”image”).
New in version 0.4.2.
Changed in version 0.4.3-dev: Renamed the method
validate_value()
tovalidate_value_attribute()
.Constructs the <input> tag.
Validates the dirname attribute for <input> tag. The dirname attribute’s value should always have the name of the input field, followed by ”.dir”.
Validates input tag attribute. Some of the input attributes depend on the input type given by the consumer.
For example, max and min attributes works with the following input types: number, range, date, datetime, datetime-local, month, time and week.
Validates the max attribute whether it is an integer/float/datetime value.
Validates the value attribute for <input> tag. The value attribute cannot be used with <input type=”file”>.