This library is based on the sources and definitions of yattag with the fondamental difference that BeautifulSoup is used as the html renderer.
Differences between bs4tag and yattag
* At this time, only SimpleDoc has been converted, Doc class is work in progress. *
No support for custom indentation (indent)
stag_end option is not available
The SimpleDoc/Doc object contains a BeautifulSoup intance in the soup attribute
asis() and ttls() functions added to SimpleDoc
( tutorial for both libraries: yattag.org and BS4)
Basic example
Nested html tags, no need to close tags, same as yattag.
from bs4tag import Doc
doc, tag, text = Doc().tagtext()
with tag('html'):
with tag('body', id = 'hello'):
with tag('h1'):
text('Hello world!')
print(doc.getvalue())
With BeautifulSoup added functionalities
Insert bs4tag document into a BeautifulSoup instance.
def body_text():
doc, tag, text = SimpleDoc().tagtext()
with tag('h1'):
text('Hello world!')
return doc.soup
doc, tag, text = SimpleDoc().tagtext()
with tag('html'):
with tag('body', id='hello'):
pass
doc.soup.find(id='hello').append(body_text())
print(doc.getvalue())
# <html><body id="hello"><h1>Hello world!</h1></body></html>
Installation
pip3 install bs4tag
This library is compatible with the tutorial on yattag.org
GitHub repo: https://github.com/ceprio/bs4tag Derived from: https://github.com/leforestier/yattag
Metadata
Release files for bs4tag 0.1.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 |
|---|---|---|---|---|
| bs4tag-0.1.0.tar.gz | 27.8 kB | Without provenance | Details for bs4tag-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bs4tag-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bs4tag-0.1.0-py3-none-any.whl |
Total release size: 56.1 kB
Release files / bs4tag-0.1.0.tar.gz
| Download URL | bs4tag-0.1.0.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c80419004322c17a0988a0ca4f6bd38ecc77380aa5844ead5390bc9a8da93b24
|
|
BLAKE2b-256 checksum How to use checksums |
fe41d8fc6feaaca3d4fa066537014391e871c33af3e78056ee513328b655b05a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7
|
Release files / bs4tag-0.1.0-py3-none-any.whl
| Download URL | bs4tag-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f63e3276de59fffbddf6c12bfe7fe0a70e0a740f979b5a0ddf266f0498d8b6d
|
|
BLAKE2b-256 checksum How to use checksums |
d1e68b6b50c8c5dd583723049fe05816f6c46caff3d2f19a1a2f632e3a387a86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7
|
Security for bs4tag 0.1.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.