Overview
This project allows you to translate markdown to HTML and to convert URLs or even local image file-paths to embedded images.
Local file-paths must be specifically enabled, for security reasons.
This project is Python 2 and Python 3 compatible.
Example
Image URLs
Short usage:
import mei markdown = "" actual = mei.markdown(markdown) # <p><img src="data:image/png;base64,iVBORw0KGgoAAAANSU...kJggg==" alt="Random Ingenuity"></p>
Long usage:
import mei.embed_images import mistune renderer = mei.embed_images.EmbedImagesRenderer() m = mistune.Markdown(renderer=renderer) markdown = "" actual = m.render(markdown) # <p><img src="data:image/png;base64,iVBORw0KGgoAAAANSU...kJggg==" alt="Random Ingenuity"></p>
Local Images
Short usage:
import mei markdown = "" actual = mei.markdown(markdown) # <p><img src="data:image/png;base64,iVBORw0KGgoAAAANSU...TkSuQCC" alt="Random Ingenuity"></p>
Long usage:
import mei.embed_images import mistune renderer = mei.embed_images.EmbedImagesRenderer(embed_local_images=True) m = mistune.Markdown(renderer=renderer) markdown = "" actual = m.render(markdown) # <p><img src="data:image/png;base64,iVBORw0KGgoAAAANSU...TkSuQCC" alt="Random Ingenuity"></p>
Testing
Just run the test script:
$ ./test.sh test_embed_images_local (test_embed_images.TestEmbedImages) ... ok test_embed_images_url (test_embed_images.TestEmbedImages) ... ok test_get_base64_with_image_filepath (test_embed_images.TestEmbedImages) ... ok test_get_base64_with_image_url (test_embed_images.TestEmbedImages) ... ok test_get_embedded_image_filepath (test_embed_images.TestEmbedImages) ... ok test_get_embedded_image_filepath__xhtml (test_embed_images.TestEmbedImages) ... ok test_get_embedded_image_url (test_embed_images.TestEmbedImages) ... ok test_get_embedded_image_url__xhtml (test_embed_images.TestEmbedImages) ... ok test_get_http2 (test_embed_images.TestEmbedImages) ... ok test_get_http3 (test_embed_images.TestEmbedImages) ... ok test_http (test_embed_images.TestEmbedImages) ... ok test_http__instance_cached (test_embed_images.TestEmbedImages) ... ok test_markdown (test_embed_images.TestEmbedImages) ... ok ---------------------------------------------------------------------- Ran 13 tests in 0.016s OK
Metadata
Release files for markdown-embedimages 0.1.4
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 | |
|---|---|---|---|---|
| markdown-embedimages-0.1.4.tar.gz | 3.9 kB | Without provenance | Details |
Release files / markdown-embedimages-0.1.4.tar.gz
| Download URL | markdown-embedimages-0.1.4.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b5d6eb8b6232e16d17039219b64c32a34ca13eedf9d036e6ba7663c7ad012b3
|
|
BLAKE2b-256 checksum How to use checksums |
837b2d76d87407abb854f1244dccdf1795b559d83eed9e2ef4f34a95be19faae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for markdown-embedimages 0.1.4
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.