simplestyle
This package was originally part of a Python tool to extract text data from PDFs into TEI XML. Some of the style information that was extracted from the PDF had to be recorded in the resulting TEI file. Among these were fontname, fontsize, italics, boldface, superscript, subscript. These were included as simple CSS statements into the tagsDecl of the TEI document.
Later it seemed approporiate to remove this very simple style library from the PDF extraction package and offer it as a little standalone package, which can be useful in different contexts.
NB: This package might be useful for some people, hence it is published as an open source package, but it is still very much tailored to some very special needs for text processing. It is not very likely that this package will be developed into a general CSS library. If you need this, you will find plenty of helpful libraries on PyPI.
Download, Installation
simplestyle is available on PyPI <https://pypi.python.org/pypi/simplestyle>.
Install with pip install simplestyle.
The source code is on GitHub: <https://github.com/rotula/simplestyle>.
Simplified CSS
The simplified CSS grammar understood by this package is as follows:
css := declaration (";" declaration)* ';'?
declaration := property ":" expr
property := [a-zA-Z-]+
expr := (string | [^;"']+)
string := string1 | string2
string1 := "'" [^'\n\r\f] "'"
string2 := '"' [^"\n\r\f] '"'
Usage
>>> from simplestyle import Style
>>> css = "font-size: 10pt"
>>> style = Style()
>>> style.from_css(css)
>>> style.size
10.0
>>> style.get_css()
'font-size: 10.0pt'
>>> style.italics
False
>>> style.from_css("font-style:italic", merge=True)
>>> style.italics
True
>>> style.size
10.0
>>> style.get_css()
'font-size: 10.0pt; font-style: italic'
>>> style.reset()
>>> style.get_css()
''
Metadata
Release files for simplestyle 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplestyle-1.2.0.tar.gz | 7.1 kB | Without provenance | Details for simplestyle-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simplestyle-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for simplestyle-1.2.0-py3-none-any.whl |
Total release size: 13.7 kB
Release files / simplestyle-1.2.0.tar.gz
| Download URL | simplestyle-1.2.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41f21ace8443f48796c311283bba1cfccceecce619c46927707a7d95ff550ef0
|
|
BLAKE2b-256 checksum How to use checksums |
a461992b38952251603f43028a10efe95790d7d0633be65bf1040da93dd7887d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / simplestyle-1.2.0-py3-none-any.whl
| Download URL | simplestyle-1.2.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1b3ec203ffee584879de38376035c1883d6c6fcbf82c4e4d1e514a7d0a3ac35
|
|
BLAKE2b-256 checksum How to use checksums |
2653eb8e2f160a7c552f124c3c87c63e4cc25e9d1a408f0ae7bd88516c39b2f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for simplestyle 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.