Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonw/datasette-simple-html
Datasette SQL functions for very simple HTML operations
https://github.com/simonw/datasette-simple-html
datasette-plugin
Last synced: about 1 month ago
JSON representation
Datasette SQL functions for very simple HTML operations
- Host: GitHub
- URL: https://github.com/simonw/datasette-simple-html
- Owner: simonw
- License: apache-2.0
- Created: 2023-03-01T02:29:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T17:30:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T07:53:36.964Z (3 months ago)
- Topics: datasette-plugin
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datasette-simple-html
[![PyPI](https://img.shields.io/pypi/v/datasette-simple-html.svg)](https://pypi.org/project/datasette-simple-html/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-simple-html?include_prereleases&label=changelog)](https://github.com/simonw/datasette-simple-html/releases)
[![Tests](https://github.com/simonw/datasette-simple-html/workflows/Test/badge.svg)](https://github.com/simonw/datasette-simple-html/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-simple-html/blob/main/LICENSE)Datasette SQL functions for very simple HTML operations
## Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-simple-html
## Usage
This plugin provides the following SQL functions:
### html_strip_tags(text)
Returns the text with any `<...>` tags removed.
### html_escape(text)
Escapes any HTML special characters in the text, e.g. `>` becomes `>`. Uses [html.escape(text, quote=True)](https://docs.python.org/3/library/html.html#html.escape) from the Python standard library.
### html_unescape(text)
Unescapes any HTML special characters, so `>` becomes `>`. Also handles numeric entities, so `'` becomes `'`. Uses [html.unescape(text)](https://docs.python.org/3/library/html.html#html.unescape) from the Python standard library.
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-simple-html
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest