Skip to main content

A basic internal XML-generating DSL in Python 3.

Project description

PyMarkup

Build Status Documentation Status

An internal DSL for generating XML-like markup in Python 3.7

Installation

Installation is as simple as pip install pymarkup. To develop, download the source, and run pip install -e .[dev]

Usage

A basic example:

from pymarkup import MarkupBuilder

t = MarkupBuilder()

with t:  # <html> tag
    with t.h1(id='HelloWorld'):  # Attribute access creates new element, and call adds attributes to tag
        t + 'Hello World!'  # Add child text to tag

    with t.a(href="github.com"):
        t + t.img(src="i_am_an_image.png")  # Self-closing tags are added with +
    with t.ul:
        for x in range(2):
            with t.li:
                t + x

repr(t) gives:

<html>
<h1 id="HelloWorld">
Hello World!
</h1>
<a href="github.com"><img src="i_am_an_image.png"/>
</a>
<ul>
<li>
0
</li>
<li>
1
</li>
</html>

For more information, see the docs

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

pymarkup-0.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pymarkup-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pymarkup-0.0.1.tar.gz.

File metadata

  • Download URL: pymarkup-0.0.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pymarkup-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e26ead0ad2edd7a720aa741872a5ea1bc59696743e68232b968dcaa3e14609c8
MD5 f451eba7e0cc6a2dfc6b01d8f0d05b15
BLAKE2b-256 09d917b475b9108fb86c13104bf487d8921bed90857909434e1896d7669750bc

See more details on using hashes here.

File details

Details for the file pymarkup-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pymarkup-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pymarkup-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6bfd2c083b4b5b6adc2b9a8368819444f2dcb24752bb5f3867a0ccd354e7c22f
MD5 5c393a7c5e81c27295182dce4749101a
BLAKE2b-256 0ea89b105e0b1ad040c8326024287cc39dea27a7a1719ab016a767b868820aae

See more details on using hashes here.

Supported by

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