Skip to content

beultra/wikitextplain

 
 

Repository files navigation

wikitexthtml

GitHub License GitHub Tag GitHub commits since latest release

GitHub Workflow Status (Testing) GitHub Workflow Status (Release)

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

pip install wikitexthtml

Or for development work:

python3 -m venv .env
.env/bin/pip install -e .

Usage

Extend Page by implementing the missing functions as seen in 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 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:

class WikiPage(Page):
    ...

print(WikiPage("Main Page").render().html)

About

Library to render WikiText to Plain text

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.8%
  • Makefile 0.2%