Frequently Asked Questions

Frequently Asked Questions

Licensing & Open Source

What license does Aspose.HTML FOSS for Python use?

The library is released under the MIT License. The full text ships as the LICENSE file in the GitHub repository.

Can I use it in commercial products?

Yes. The MIT License permits commercial use, modification, redistribution, and sublicensing. The only requirement is keeping the copyright notice and license text with substantial copies.

Installation & Requirements

How do I install the library, and which Python versions are supported?

Install from PyPI with pip install aspose-html-foss. The library requires Python 3.10 or later; the current release is 0.1.0.

Are there any native dependencies?

No. The implementation is pure Python — no browser engine, no compiled extensions — so it behaves identically on Windows, Linux, and macOS, including CI runners and containers.

API Usage

How do I parse HTML into a document?

Use HTMLDocument.parse() for complete pages or HTMLDocument.parse_fragment() for partial markup. For programmatic construction, Document is the node factory:

from aspose_html.dom import Document
doc = Document()
el = doc.create_element("div")
el.set_attribute("id", "bar")
doc.append_child(el)

How do I apply CSS and read the resulting style?

Parse stylesheet text with CSSStyleSheet.replace_sync(), attach it with Document.attach_style_sheet(), and read the resolved outcome with Element.get_computed_style():

from aspose_html.cssom import CSSStyleSheet
sheet = CSSStyleSheet()
sheet.replace_sync("#bar { color: blue }")
doc.attach_style_sheet(sheet)
print(el.get_computed_style().get_property_value("color"))

Does the cascade handle specificity and !important correctly?

Yes. Computed values follow selector specificity (ID beats class beats type), inline declarations outrank author rules, and !important author rules outrank non-important inline declarations. Inheritance flows parent to child for inheritable properties.

Can I use the tokenizer and tree builder directly?

Yes — Tokenizer.tokenize() emits the standards token stream, TreeBuilder.run() performs tree construction, and parse_html() wraps the whole pipeline in one call.

How do I work with URLs and character encodings?

URL.parse() and URL.can_parse() provide WHATWG-style URL handling with URLSearchParams for query strings. For raw bytes, detect_encoding() returns the encoding, a confidence level, and decoded text.

Known Limitations

Are any APIs present but not implemented?

A small number of members are declared but not currently functional, including CSSRule.type, CSSRule.css_text, and HTMLImageElement.decode. The limitations.md file in the knowledge model tracks these; avoid relying on them.

Does the library render pages or convert to other formats?

No. The current release focuses on parsing, DOM manipulation, CSS style computation, layout structures, URLs, and encodings. It does not ship format conversion or image/PDF rendering.

Is JavaScript executed automatically during parsing?

No. Parsing never runs scripts. Script evaluation is explicit and opt-in through JSContext, with module loading controlled by ModuleRegistry and ModuleLoadPolicy.

See Also