From c7c62c5aef8bf116ce0ba0924e574f4d8ac84cf4 Mon Sep 17 00:00:00 2001 From: tsutsu3 Date: Wed, 13 Jan 2021 21:24:04 +0900 Subject: [PATCH] Update readme (#24) --- README.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0763763..bd45d54 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![CI](https://github.com/tsutsu3/linkify-it-py/workflows/CI/badge.svg?branch=main)](https://github.com/tsutsu3/linkify-it-py/actions) [![pypi](https://img.shields.io/pypi/v/linkify-it-py)](https://pypi.org/project/linkify-it-py/) +[![Anaconda-Server Badge](https://anaconda.org/conda-forge/linkify-it-py/badges/version.svg)](https://anaconda.org/conda-forge/linkify-it-py) [![codecov](https://codecov.io/gh/tsutsu3/linkify-it-py/branch/main/graph/badge.svg)](https://codecov.io/gh/tsutsu3/linkify-it-py) [![Maintainability](https://api.codeclimate.com/v1/badges/6341fd3ec5f05fde392f/maintainability)](https://codeclimate.com/github/tsutsu3/linkify-it-py/maintainability) @@ -25,6 +26,12 @@ Why it's awesome: pip install linkify-it-py ``` +or + +```bash +conda install -c conda-forge linkify-it-py +``` + ## Usage examples ### Example 1. Simple use @@ -82,28 +89,28 @@ print(linkify.match("Site tamanegi.onion!")) ### Example 3. Add twitter mentions handler ```python -from linkify import LinkfiyIt +from linkify_it import LinkifyIt -linkifyit = LinkifyIt() +linkify = LinkifyIt() -def validate(self, text, pos): +def validate(obj, text, pos): tail = text[pos:] - if not self.re.get("twitter"): - self.re["twitter"] = re.compile( - "^([a-zA-Z0-9_]){1,15}(?!_)(?=$|" + self.re["src_ZPCc"] + ")" + if not obj.re.get("twitter"): + obj.re["twitter"] = re.compile( + "^([a-zA-Z0-9_]){1,15}(?!_)(?=$|" + obj.re["src_ZPCc"] + ")" ) - if self.re["twitter"].search(tail): + if obj.re["twitter"].search(tail): if pos > 2 and tail[pos - 2] == "@": return False - return len(self.re["twitter"].search(tail).group()) + return len(obj.re["twitter"].search(tail).group()) return 0 -def normalize(self, m): - m.url = "https://twitter.com/" + re.sub(r"^@", "", m.url) +def normalize(obj, match): + match.url = "https://twitter.com/" + re.sub(r"^@", "", match.url) -linkifyit.add("@", {"validate": validate, "normalize": normalize}) +linkify.add("@", {"validate": validate, "normalize": normalize}) ```