Every element method onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nishad12323/py2html/llms.txt
Use this file to discover all available pages before exploring further.
Parent appends a tag descriptor dictionary to self.tags and returns the integer index of the newly added element. That index can be used later with page[index] to inspect the descriptor, or del page[index] to remove the element. All text and content arguments are HTML-escaped via escapeCharacters() before storage unless otherwise noted.
Button
<button> element to the document.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Inner text of the button. HTML-escaped before rendering.
Horizontal padding in pixels — maps to the
padding shorthand as
padding: {pady}px {padx}px.Vertical padding in pixels — maps to the
padding shorthand as
padding: {pady}px {padx}px.int — the index of the new element in self.tags.
Label
<p> (paragraph) element to the document. Use this for short, block-level text labels.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Inner text of the paragraph. HTML-escaped before rendering.
Horizontal padding in pixels.
Vertical padding in pixels.
int — the index of the new element in self.tags.
Text
<textarea> element to the document. Suitable for pre-filled or read-only text areas.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Default content shown inside the textarea. HTML-escaped before rendering.
Horizontal padding in pixels.
Vertical padding in pixels.
int — the index of the new element in self.tags.
Heading
<h1> through <h6>) to the document.
Heading level. Must be an integer between
1 and 6 (inclusive). Raises
ValueError for any other value.Heading text. HTML-escaped before rendering.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Horizontal padding in pixels.
Vertical padding in pixels.
int — the index of the new element in self.tags.
Raises: ValueError — if level is not between 1 and 6.
Image
<img /> element to the document.
URL or path to the image file — rendered as the
src attribute. The value
is HTML-escaped when output.Alternative text for the image — rendered as the
alt attribute. The value
is HTML-escaped when output.CSS width value (e.g.,
"200px", "100%"). When None, no width style
is emitted.CSS height value (e.g.,
"150px"). When None, no height style is
emitted.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property. Useful for
circular avatars.int — the index of the new element in self.tags.
Link
<a> hyperlink element to the document.
The URL the link points to — rendered as the
href attribute.Visible link text. HTML-escaped before rendering.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Horizontal padding in pixels.
Vertical padding in pixels.
Text decoration — maps to the CSS
text-decoration property.
Pass "none" to remove the default underline.int — the index of the new element in self.tags.
Frame
<div> container element to the document. content can be a plain string or another Parent instance for nested layouts.
Text color — maps to the CSS
color property.Background color — maps to the CSS
background property.Border shorthand — maps to the CSS
border property.Border radius — maps to the CSS
border-radius property.Inner content of the
<div>. When a str, it is HTML-escaped. When a
Parent object, its tags list is rendered recursively as the div’s
children.Horizontal padding in pixels.
Vertical padding in pixels.
CSS width of the div — maps to the
width property.CSS height of the div — maps to the
height property.Horizontal margin — used in the CSS shorthand
margin: {marginy} {marginx}.Vertical margin — used in the CSS shorthand
margin: {marginy} {marginx}.CSS
display value for the div. Set to "flex" to activate flexbox layout,
which uses the values from flex_config.Flexbox configuration applied when
content_manager="flex". Supports the
following keys: align-items, justify-content, flex-direction,
flex-wrap, and gap.CSS
position value — e.g., "relative", "absolute", "fixed".CSS offset values applied alongside
position. Supports top, left,
right, and bottom keys.int — the index of the new element in self.tags.
Script
<script> element to the document. Use code for inline JavaScript or src to reference an external file. Additional keyword arguments become HTML attributes on the tag.
Inline JavaScript to embed between
<script> and </script>. This content
is never HTML-escaped — it is stored and rendered exactly as provided.URL or path to an external JavaScript file. Rendered as the
src attribute.
The value is HTML-escaped when output.Additional HTML attributes, e.g.,
defer=True, type="module". Each
key-value pair is serialised as key="value" on the opening tag.int — the index of the new element in self.tags.
Because the
<script> tag’s content bypasses escapeCharacters(), you can
embed arbitrary JavaScript including template literals, comparison operators
(<, >), and string quotes without worrying about HTML encoding.TextNode
page(...) (the __call__ shorthand) uses internally.
The text content to insert. When
escape=True, passed through
escapeCharacters(). When escape=False, inserted verbatim.Controls HTML escaping. Set to
False to inject raw HTML fragments directly
into the document.int — the index of the new text node in self.tags.
CustomTag
The HTML tag name to render, e.g.,
"section", "article", "nav",
"span".Inner content. When a
str, it is HTML-escaped. When a Parent object,
its tags are rendered recursively as children (without the outer wrapper).Text color — maps to the CSS
color property. Omitted from the style
attribute when None.Background color — maps to the CSS
background property. Omitted when
None.Border shorthand — maps to the CSS
border property. Omitted when None.Border radius — maps to the CSS
border-radius property. Omitted when
None.Horizontal padding in pixels. Padding is only applied when both
padx
and pady are provided.Vertical padding in pixels. Padding is only applied when both
padx and
pady are provided.Additional HTML attributes rendered on the tag, e.g.,
id="main",
class_="container". Attribute values are HTML-escaped.int — the index of the new element in self.tags.