B64
Overview
B64 allows for the embedding of local PNG, JPEG, and GIF image references with base64 encoding. It simply needs a base
path to resolve relative links in the Markdown source. The base path is the assumed location of the Markdown source at
time of conversion. Using the base path, B64 will search and find the actual img tag references (both absolute and
relative) and base64 encode and embed them in the HTML output.
If you would like to distribute a Markdown output without having to also distribute the images separately, B64 can help. In a normal website, this would probably not be desired.
<p><img alt="picture" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAqFBMVEU5eZdll66Yucjd7h7d7h7d7h5ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll65ll66YuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYuciYucgXVONTAAABDklEQVRoge3XR3ICQRBE0b/Ce2+FAAnkLeb+N9MRNBvFR0H2vuJFT3dX5VAqV6q1eqPZane6vf5gOBpPprP5YnnD72t1u95s7+53+4fHp+eX17f3j8+v78PxdC5Qi+SWkNwykltBcqtIbg3JrSO5DSS3ieS2kNw2kttBcrtIbg/J7SO5AyR3iOSOkNwxkjtBcqdI7gzJnSO5CyR3WaD0T1xrv3Hjxo0bN27cuHHjxo0bN27c63Sx9ov1nbHOF+teYd1nrHeE9X6x+gZWv8Lqk1j9GWsuYM0jrDmINX+x5j5W3sDKOVj5CivXYeVJrByLlZ+xcnuB0n/5vxA3bty4cePGjRs3bty4cePGvUj3B2JzyvcNRmTGAAAAAElFTkSuQmCC" />
The B64 extension can be included in Python Markdown by using the following:
Link Restrictions
New 11.0
By default, only images that are children under base_path are evaluated. This prevents images from being processed
unexpectedly outside the intended folder structure. Links are only restricted if restrict_path is enabled, which is
the default.
Because there are legitimate cases in which paths may be desired as relative to the target file, a parent separate from
base_path bay occasionally be desired. In such cases, root_path can also be specified which will allow links to be
relative to base_path without needing to be children of base_path as long as they are contained under root_path.
Options
| Option | Type | Default | Description |
|---|---|---|---|
base_path |
string | '.' |
A string indicating a base path to be used to resolve relative links. |
root_path |
string | '' |
A string indicating a root path that links should be children of if restrict_path is enabled. |
restrict_path |
bool | True |
Restricts image evaluation such that links that are not children of base_path are ignored. If root_path is specified links can be relative to base_path as long as they are children of root_path. |