UNKNOWN
Project description
The Repo extracts url/email substring from given string and converts it into links(or any customized format).Currenty, we apply HTML and MARKDOWN replacement type, and also apply easy way to customize the replacement.
Installation
Installation using pip:
pip install autolink_py
Usage
replace URL with html format
from autolink_py.core import AutoLinker
text = 'This website is google.com'
al = AutoLinker()
new_text = al.linkify(text, replaced_type='HTML')
# new_text -> 'This website is <a href="http://google.com">google.com</a>'
replace URL with markdown format
from autolink_py.core import AutoLinker
text = 'This website is google.com'
al = AutoLinker()
new_text = al.linkify(text, replaced_type='MARKDOWN')
# new_text -> 'This website is [google.com](http://google.com)'
replace URL with customized format
# example: 'google.com' -> '<google.com><http://google.com>'
from autolink_py.core import AutoLinker
class NewAutoLinker(AutoLinker):
def replace_url(self, text, url):
'''
implement replace_url to customize the format you need.
Params:
text: url text that shown originally
url: newly generated link including complete protocal based on text.
'''
return u'<{0}><{1}>'.format(text, url)
text = 'The website is google.com'
nal = NewAutoLinker()
new_text = nal.linkify(text)
# new_text -> 'The website is <google.com><http://google.com>'
Credits
The core algorithm is referred by the open source Repo: autolink
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
autolink_py-0.2.1.tar.gz
(5.2 kB
view details)
File details
Details for the file autolink_py-0.2.1.tar.gz
.
File metadata
- Download URL: autolink_py-0.2.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf09714fad5f144565b7b650991dddbfe3adcb5fa4bcd0778f40bda3c266169a |
|
MD5 | 0964175394109ad822b08e0fe5206430 |
|
BLAKE2b-256 | 879998ee29fd10cd2b2e42d752a1c7d42387b7f4740d2b227a993dbcf3fd0cbe |