autolink_py-0.2.1
توضیحات
UNKNOWN
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | autolink_py-0.2.1 |
| نام | autolink_py |
| نسخه کتابخانه | 0.2.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Tzeng |
| ایمیل نویسنده | tseng0211@gmail.com |
| آدرس صفحه اصلی | https://github.com/joanne-tseng/autolink_py |
| آدرس اینترنتی | https://pypi.org/project/autolink_py/ |
| مجوز | UNKNOWN |
autolink_py
============
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``:
.. code-block:: bash
pip install autolink_py
Usage
------
- replace URL with html format
.. code-block:: python
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
.. code-block:: python
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
.. code-block:: python
# 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 <https://github.com/Suor/autolink>`_
نحوه نصب
نصب پکیج whl autolink_py-0.2.1:
pip install autolink_py-0.2.1.whl
نصب پکیج tar.gz autolink_py-0.2.1:
pip install autolink_py-0.2.1.tar.gz