Markdown Extension for Hashtags
This is an extension for Python-Markdown to support hashtag parsing to clickable links.
# Heading
#hashtag at beginning of line and #within line.
This is no#hashtag.
#Markdown
will be rendered to:
<h1>Heading</h1>
<p><a class="hashtag" href="https://tags.example.com/hashtag">#hashtag</a> at beginning of line and <a class="hashtag" href="https://tags.example.com/within">#within</a> line.</p>
<p>This is no#hashtag. </p>
<p><a class="hashtag" href="https://tags.example.com/Markdown">#Markdown</a></p>
You can easily specify the used link prefix and the class name of the link, see # Usage below.
Installation
The markdown-hashtag package can be installed via:
pip install markdown-hashtag
Usage
The following python code example shows how to use the hashtag extension and style the hashtag links in a pretty way with CSS (similar to how Obsidian renderns hashtags).
Note that you can define the link prefix of the href attribute and the class name by defining extension_configs in the markdown.markdown() function, see example.
import markdown
text = """\
# Heading
#hashtag at beginning of line and #within line.
This is no#hashtag.
#Markdown
<style>
a.hashtag {
background-color: #e0e0e0; /* hellgrauer Hintergrund */
border-radius: 4px; /* abgerundete Ecken */
padding: 2px 6px; /* innen etwas Abstand */
color: #3b6ea5; /* blaue Farbe für Links */
text-decoration: none; /* keine Unterstreichung */
font-weight: 500; /* etwas fetter */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
cursor: pointer;
transition: background-color 0.2s ease;
}
a.hashtag:hover {
background-color: #cfd8dc; /* dunkleres Grau beim Hover */
text-decoration: underline; /* Unterstreichung beim Hover */
}
</style>
"""
html = markdown.markdown(text,
extensions=["hashtag"],
extension_configs={
"hashtag": {
"base_url": "https://tags.example.com/",
"span_class": "hashtag"
}
}
)
print(html)
The result looks like this:
License
This project is licensed under the terms of the GNU General Public License v3.0.
See the LICENSE file for details.
Metadata
Release files for markdown-hashtag 0.1.1
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_hashtag-0.1.1.tar.gz | 16.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markdown_hashtag-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.6 kB
Release files / markdown_hashtag-0.1.1.tar.gz
| Download URL | markdown_hashtag-0.1.1.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d1bd77eb02f7ae51de00b3bfda55f653d10564bea0a98491a1eb9d7b794dd1d
|
|
BLAKE2b-256 checksum How to use checksums |
cd75cc50f92433e6175fe4f408a0e0b3b3dfda9f51d2637e57a1a00052cf05d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / markdown_hashtag-0.1.1-py3-none-any.whl
| Download URL | markdown_hashtag-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bd10b750a3304aae6861691fd5b1a162835e07c22cdaabd9b8b396065317722
|
|
BLAKE2b-256 checksum How to use checksums |
187b15ecf828d67141ede79ca3fdbbec0626f68c4738fee68247e4ddb7a89da2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for markdown-hashtag 0.1.1
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.