Skip to main content

A basic MediaWiki markup parser.

Project description

Summary

Formats text following the MediaWiki syntax.

Usage

To return HTML from Wiki:

from wikimarkup.parser import Parser

parser = Parser()
html = parser.parse(text[, show_toc=True])

To return HTML without certain “annoying” (TODO: define annoying) elements, such as headings:

from wikimarkup.parser import parselite

parselite(text)

Adding New Tags

You can add new tags with the registerTagHook method.:

from wikimarkup.parser import Parser
import cgi

def blockquoteTagHook(parser_env, body, attributes={}):
    """<quote[ cite="Person"]>A paragraph of text.</quote>"""
    text = ['<blockquote>']
    if 'cite' in attributes:
        text.append('<cite>%s</cite>' % (cgi.escape(attributes['cite']),))
    text.append(parse(body.strip()))
    text.append('</blockquote>')
    return u'\n'.join(text)

parser = Parser()
parser.registerTagHook('quote', blockquoteTagHook)

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

py-wikimarkup-2.3.0.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

py_wikimarkup-2.3.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file py-wikimarkup-2.3.0.tar.gz.

File metadata

  • Download URL: py-wikimarkup-2.3.0.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for py-wikimarkup-2.3.0.tar.gz
Algorithm Hash digest
SHA256 7081ab990afb95bf9d55b762a3db6f779838844a8de0bf8d2589443a6e378e1c
MD5 4313b4dadda1f3b144d608222cb66c9f
BLAKE2b-256 314a6ea908153b339aafcf4dd25a3a391c0d23efb39f2d21748725f8f2708e44

See more details on using hashes here.

File details

Details for the file py_wikimarkup-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_wikimarkup-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90060fbdfda0e2c611d04fe963be4a9e894f12cb28a21d2d515fe504925fc55b
MD5 9795ef91f325a8ddb077cfbb05caf995
BLAKE2b-256 06cdc56a20509043b194aab20ac0e1f23bbfcfc284f105c779640c6f9b8f6dd4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page