https://github.com/truebrain/wikitexthtml
Library to render WikiText to HTML
https://github.com/truebrain/wikitexthtml
Last synced: 8 months ago
JSON representation
Library to render WikiText to HTML
- Host: GitHub
- URL: https://github.com/truebrain/wikitexthtml
- Owner: TrueBrain
- License: lgpl-3.0
- Created: 2020-10-26T08:13:56.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T09:48:59.000Z (about 3 years ago)
- Last Synced: 2025-07-16T14:42:58.600Z (11 months ago)
- Language: Python
- Size: 85 KB
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wikitexthtml
[](https://github.com/TrueBrain/wikitexthtml/blob/main/LICENSE)
[](https://github.com/TrueBrain/wikitexthtml/releases)
[](https://github.com/TrueBrain/wikitexthtml/commits/main)
[](https://github.com/TrueBrain/wikitexthtml/actions/workflows/testing.yml)
[](https://github.com/TrueBrain/wikitexthtml/actions/workflows/release.yml)
wikitexthtml is a library that renders HTML from WikiText.
## Dependencies
- Python3.8 or higher.
- `python-slugify` (via `setup.py`), for slugs in anchors
- `ply` (via `setup.py`), to implement `{{#ifexpr}}` and `{{#expr}}`
- `wikitextparser` (via `setup.py`), to make sense of wikitext
## Installation
```bash
pip install wikitexthtml
```
Or for development work:
```bash
python3 -m venv .env
.env/bin/pip install -e .
```
## Usage
Extend [Page](https://github.com/TrueBrain/wikitexthtml/blob/main/wikitexthtml/page.py) by implementing the missing functions as seen in [prototype.py](https://github.com/TrueBrain/wikitexthtml/blob/main/wikitexthtml/prototype.py).
This way you can customize where files are read from (from disk, from a database, etc) and how to sanitize titles and URLs.
In the [tests](https://github.com/TrueBrain/wikitexthtml/tree/main/tests/) folder examples of this can be found.
Now you can instantiate this new class and call `render()` on it.
The result will be available in `html`. For example:
```python
class WikiPage(Page):
...
print(WikiPage("Main Page").render().html)
```