Skip to main content

Datasette plugin that renders specified cells as HTML

Project description

datasette-render-html

PyPI Changelog Tests License

This Datasette plugin lets you configure Datasette to render specific columns as HTML in the table and row interfaces.

This means you can store HTML in those columns and have it rendered as such on those pages.

If you have a database called docs.db containing a glossary table and you want the definition column in that table to be rendered as HTML, you would use a metadata.json file that looks like this:

{
    "databases": {
        "docs": {
            "tables": {
                "glossary": {
                    "plugins": {
                        "datasette-render-html": {
                            "columns": ["definition"]
                        }
                    }
                }
            }
        }
    }
}

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-render-html

Usage

With the plugin installed, launch Datasette with the above metadata.json configuration:

$ datasette -m metadata.json docs.db

Security

This plugin allows HTML to be rendered exactly as it is stored in the database. As such, you should be sure only to use this against columns with content that you trust - otherwise you could open yourself up to an XSS attack.

It's possible to configure this plugin to apply to columns with specific names across whole databases or the full Datasette instance, but doing so is not safe. It could open you up to XSS vulnerabilities where an attacker composes a SQL query that results in a column containing unsafe HTML.

As such, you should only use this plugin against specific columns in specific tables, as shown in the example above.

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

datasette-render-html-1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_render_html-1.0-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file datasette-render-html-1.0.tar.gz.

File metadata

  • Download URL: datasette-render-html-1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for datasette-render-html-1.0.tar.gz
Algorithm Hash digest
SHA256 8e7a9ab21caed72cf42ebef4cecb0e84a6d2068e4681b4eeddfc48c5379949ab
MD5 606a5995ef8de17f73cdc9b59e3de058
BLAKE2b-256 763287bb45b4f790041575429fdf04681c6ef5a4104c4d710054c83a2b9391a9

See more details on using hashes here.

File details

Details for the file datasette_render_html-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_render_html-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6437c015bfb25bef983451b3840fc81fe9c1636c3158064d6ce04dde0f850f2
MD5 0a4797d5eb3eb577f645dd8d522a8889
BLAKE2b-256 23fe2ff9b3952ddd442004a44c78beee8dd842dae2ac16e9a7baa98329ebeea7

See more details on using hashes here.

Supported by

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