melon-parse
Parse a Wikipedia page into Melon-mode: a clean, distraction-free, paginated focus-mode reader, emitted as machine-readable JSON.
This is a Python port of the encyclopedic reader from the Melon browser
— the same rules that strip Wikipedia's chrome (navboxes, hatnotes, edit links, [1] markers, the
"From Wikipedia, the free encyclopedia" tagline in ~50 languages), capture the infobox / data
tables / image gallery / references / interlanguage links as structured data, and split the
article into one coherent top-level section per page for focus-mode reading.
Install
pip install melon-parse
Use — library
import melon_parse
article = melon_parse.parse("https://en.wikipedia.org/wiki/Watermelon")
# or a bare title: melon_parse.parse("Watermelon", lang="en")
print(article.title, "—", len(article.sections), "focus-mode pages")
for s in article.sections:
print(f"[{s.index}] {s.title} ({len(s.blocks)} blocks)")
data = article.to_dict() # fully JSON-serializable
Use — CLI
melon-parse https://en.wikipedia.org/wiki/Watermelon # JSON to stdout
melon-parse Watermelon --lang en -o watermelon.json # bare title
melon-parse Watermelon --sections-only --indent 0 # just the pages, compact
melon-parse --html saved.html --url https://en.wikipedia.org/wiki/Watermelon # offline
Output schema (machine-readable)
{
"url": "https://en.wikipedia.org/wiki/Watermelon",
"title": "Watermelon",
"lang": "en",
"encyclopedic": true,
"lead_image": "https://upload.wikimedia.org/…jpg",
"section_count": 9,
"sections": [ // ← the paginated FOCUS MODE
{
"index": 0,
"title": "Watermelon", // lead page titled by the article
"anchor": null, // original-page DOM id (scroll-sync), when present
"blocks": [
{"kind": "paragraph", "text": "Watermelon (Citrullus lanatus) is a flowering plant…"},
{"kind": "heading", "level": 3, "text": "Etymology", "anchor": "Etymology"},
{"kind": "list", "items": ["…", "…"]},
{"kind": "image", "src": "https://…jpg", "caption": "A cut watermelon"},
{"kind": "quote", "text": "…"}
]
}
// …one entry per top-level (H2) section; H3/H4 subsections stay inline via {kind:"heading",level:3}
],
"infobox": {"title": "Watermelon", "image": "…", "rows": [{"label": "Kingdom", "value": "Plantae"}]},
"tables": [{"caption": "…", "section": "Nutrition", "rows": [["Energy", "127 kJ"], …]}],
"gallery": [{"src": "…", "caption": "…"}],
"references": {"1": "Smith, J. (2020)…", "2": "…"}, // [N] markers hidden from body
"languages": [{"lang": "fr", "title": "Pastèque", "url": "https://fr.wikipedia.org/wiki/Pastèque"}]
}
Block kinds
paragraph · heading (level 2–4, anchor) · image (src, caption) · list (items[]) · quote
Pagination (focus mode)
Each top-level (H1/H2) heading starts a new page; H3/H4 subsections stay inline within their parent page. A page needs ≥ 220 chars of real body before the next heading spins up a new page (empty/redundant sections like a structurally-captured "References" are dropped, not shown as header-only fragments); a thin tail page folds back into the previous one. Nothing is dropped — every real block lands in exactly one section.
Scope
Currently Wikipedia / Wikipedia-style encyclopedic pages (*.wikipedia.org/wiki/<Title>). The
Melon browser applies the same reader idea to news, blogs, and other page types; those engines may
follow here.
License
MIT © alvations
Metadata
Release files for melon-parse 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| melon_parse-0.1.0.tar.gz | 14.2 kB | Without provenance | Details for melon_parse-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| melon_parse-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for melon_parse-0.1.0-py3-none-any.whl |
Total release size: 30.5 kB
Release files / melon_parse-0.1.0.tar.gz
| Download URL | melon_parse-0.1.0.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4b3b5e4776bf8f19da9d59da14f9b38e98b7a5dc1614eec0b9bcf4bf246babb
|
|
BLAKE2b-256 checksum How to use checksums |
04a525a1c2b44cc993611e6a244fe5bb78ccb8d9d6d5432b098cff12738d716c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / melon_parse-0.1.0-py3-none-any.whl
| Download URL | melon_parse-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
444d42bf71e912d7a6eab65018341e9ea120b2b9e249916afabe9129591a5b25
|
|
BLAKE2b-256 checksum How to use checksums |
65ea2c6fc89d95756927d46584616163a445f61a979a3132eb5ccdef01f9f999
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for melon-parse 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.