Pure Rust WHATWG-compliant innerText, outerText, and textContent extraction
Project description
innertext (Python)
Pure Rust WHATWG-compliant innerText, outerText, and textContent extraction from HTML.
Installation
pip install innertext
Quick Start
import innertext
html = """
<div id="root">
Hello <span style="display:none">hidden</span> World
<script>console.log("not shown")</script>
</div>
"""
# Get rendered text (CSS-aware)
print(innertext.inner_text(html)) # "Hello World"
# Get structural text (CSS-blind)
print(innertext.text_content(html)) # "Hello hidden console.log("not shown")"
Packaging Notes
The published Python package uses a two-layer layout:
innertextis a regular Python package with a runtime__init__.py- the compiled Rust extension is loaded as
innertext._innertext
This avoids namespace-package import issues and ensures import innertext
always exposes inner_text, outer_text, and text_content.
Type Hints
This package ships with PEP 561-compatible typing metadata:
innertext/__init__.pyidefines the public API typesinnertext/py.typedmarks the package as typed
Type checkers such as mypy and pyright can therefore infer:
inner_text(html: str) -> strouter_text(html: str) -> strtext_content(html: str) -> str
API
Functions
inner_text(html: str) -> str
Extract innerText from HTML string. Implements the WHATWG innerText algorithm:
- Respects
displayCSS property (skipsdisplay:none) - Respects
visibilityCSS property - Respects
white-spaceCSS property (normal, pre, pre-line, pre-wrap) - Respects
text-transformCSS property - Handles replaced elements (textarea, input, img)
- Converts
<br>tags to newlines
outer_text(html: str) -> str
Extract outerText from HTML string. Per WHATWG spec, outerText getter is identical to innerText getter.
text_content(html: str) -> str
Extract textContent from HTML string. Performs CSS-blind structural walk:
- Ignores all CSS properties
- Includes
display:nonecontent - Includes
<script>and<style>content
Accuracy
100% Chromium parity on 36+ test cases covering:
- Display and visibility handling
- Whitespace normalization (normal, pre, pre-line)
- Block element newlines
- Table cell/row separators
- Replaced elements (textarea, input, img, button)
- Metadata elements (script, style)
- Unicode and entity handling
Performance
- Pure Rust implementation
- Zero external runtime dependencies
- <1ms per document (parsing + extraction)
- Minimal memory overhead (O(n) DOM tree)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file innertext-0.2.3.tar.gz.
File metadata
- Download URL: innertext-0.2.3.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f749f67fce749a189dabc8c84813d978f7d8cbd861e9284ca555f1f68f746ce
|
|
| MD5 |
233965ce8c115d58d7cd9b3b0f4283e6
|
|
| BLAKE2b-256 |
34337f94f7a35aed07c87484436e9ba86c36b771d33f0e3bdc307ef3904d7abe
|
Provenance
The following attestation bundles were made for innertext-0.2.3.tar.gz:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3.tar.gz -
Subject digest:
5f749f67fce749a189dabc8c84813d978f7d8cbd861e9284ca555f1f68f746ce - Sigstore transparency entry: 2141073324
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-win_amd64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 355.7 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09ba50a08a0e98598a5548b520436e233db0bab5bddb6fe7f0ea500e0b5a18ba
|
|
| MD5 |
eb53a21b9353704abe52c790c6c5dc06
|
|
| BLAKE2b-256 |
d9a9559485cbaffde46fc10e919a4144404bc66a204b3ad71eaab05ff77c39f1
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-win_amd64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-win_amd64.whl -
Subject digest:
09ba50a08a0e98598a5548b520436e233db0bab5bddb6fe7f0ea500e0b5a18ba - Sigstore transparency entry: 2141073385
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 719.4 kB
- Tags: CPython 3.7+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
084888927e95f43bb008a9ca781d477746b5d2b5fbdee5713f4b9de4b0142e2d
|
|
| MD5 |
1ed829080d47e3e2499e463cb8680ef6
|
|
| BLAKE2b-256 |
4259a76e967db85754ef7e9f73e360a57819e8e81fe8ec66ed3b077951de5131
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-musllinux_1_1_x86_64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-musllinux_1_1_x86_64.whl -
Subject digest:
084888927e95f43bb008a9ca781d477746b5d2b5fbdee5713f4b9de4b0142e2d - Sigstore transparency entry: 2141073399
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-musllinux_1_1_aarch64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 702.7 kB
- Tags: CPython 3.7+, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb23904b6ec73c1a18616811eebd11ea1192a700634680b295e36a87129e97bf
|
|
| MD5 |
8b0c95acd4cbf7f128e8391b8358cddf
|
|
| BLAKE2b-256 |
2b38a933117015ed468a4e56382ecea137b547cd3b09bd8c5b6a0fece1c7ec14
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-musllinux_1_1_aarch64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-musllinux_1_1_aarch64.whl -
Subject digest:
bb23904b6ec73c1a18616811eebd11ea1192a700634680b295e36a87129e97bf - Sigstore transparency entry: 2141073361
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 487.9 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c18531060b96c20cefa64ab90cd8755eee9ef7983a31204c614e4ecfc54c2967
|
|
| MD5 |
bd10f3947aeb295d09284906478af42c
|
|
| BLAKE2b-256 |
2376aa0d708d998d511ba4e9b1458335c3ec681a38ab46abb5c07844ca192f73
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
c18531060b96c20cefa64ab90cd8755eee9ef7983a31204c614e4ecfc54c2967 - Sigstore transparency entry: 2141073342
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 526.6 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89dc0665c41de14c7d9b90e364dc36a47216e7d8f31ff2c2c6bcb455a3c108d6
|
|
| MD5 |
7218a17dba1f1b15d56b0865121ba135
|
|
| BLAKE2b-256 |
8bb474fa4fd291baf9271fa94d6cdec3f9fb5adbbb609c87f237c7d62ab38175
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
89dc0665c41de14c7d9b90e364dc36a47216e7d8f31ff2c2c6bcb455a3c108d6 - Sigstore transparency entry: 2141073377
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 442.9 kB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
096c4cda9f33c19b87cf8ad9b944e5c33439994d7b25364f6a0fba2424f63c7a
|
|
| MD5 |
dd7b5e394cc768a323c767b2570de37b
|
|
| BLAKE2b-256 |
3f5866c2adda99f242ed5c6cf3a1dd6f01f694feb381ffe7c868baa2346ace7c
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-macosx_11_0_arm64.whl -
Subject digest:
096c4cda9f33c19b87cf8ad9b944e5c33439994d7b25364f6a0fba2424f63c7a - Sigstore transparency entry: 2141073351
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file innertext-0.2.3-cp37-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: innertext-0.2.3-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 448.6 kB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2bcfbf1ef55f0646448817bebb670edfdd79e6b213c175320a8a10cb7d001c2
|
|
| MD5 |
23c8de14681f727f198755ec14149152
|
|
| BLAKE2b-256 |
4ab93cd4e90cf5ec06e132df0df20b496919970734b930265a31e83a77c3fb4f
|
Provenance
The following attestation bundles were made for innertext-0.2.3-cp37-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish-pypi.yml on jafayer/innertext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
innertext-0.2.3-cp37-abi3-macosx_10_12_x86_64.whl -
Subject digest:
b2bcfbf1ef55f0646448817bebb670edfdd79e6b213c175320a8a10cb7d001c2 - Sigstore transparency entry: 2141073334
- Sigstore integration time:
-
Permalink:
jafayer/innertext@a71360b1658015d18b78d9c063409a1b38df4f07 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/jafayer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@a71360b1658015d18b78d9c063409a1b38df4f07 -
Trigger Event:
push
-
Statement type: