Skip to main content

XHTML mobile profile HTML transformer and cleaner for Pyhton

Project description

gomobile.xhtmlmp provides XHTML mobile profile cleaner. It takes in arbitary HTML code and turns it to valid XHTML-MP code which can be dropped in XHTML MP page.

The code will also filter possible malicious code in external feed content, like <script> tags.

Requirements

This package has no dependencies to Plone or GoMobile and can be used with any Python code.

Features

  • Turn any incoming HTML/XHTML to mobile profile compatible
    • Enforce ALT text on images - especially useful for external tracking images (feedburner tracker)
  • Protect against Cross-Site Scripting Attacks (XSS) and other nastiness, as provided by lxml.html.clean
  • Unicode compliant - eats funky characters

Usage

clean_xhtml_mp(html)

This function will do everyhing you need.

Run XHTML mobile profile cleaner for HTML code:

@param html: HTML as a string or lxml Document
@return: XHTML, utf-8 encoded string

Example:

from gomobile.xhtmlmp.transformers.xhtmlmp_safe import clean_xhtml_mp

html = '<img src="http://www.foobar.com">'
output = clean_xhtml_mp(html)
self.assertEqual(output, '<img src="http://www.foobar.com" alt=""/>', "Got:" + output)

Roadmap

Future features will include:

  • Automatic resize for image sources

Unit tests

Put gomobile.xhtmlmp to your PYTHONPATH.

Run unit tests normally like:

python tests/test_image.py

0.1

  • Initial release

Project details


Release history Release notifications

This version
History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gomobile.xhtmlmp-0.1.tar.gz (4.0 kB) Copy SHA256 hash SHA256 Source None Jul 23, 2009

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page