Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anchorman

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anchorman

Anchorman takes a list of terms and a text. It finds the terms in this text and replaces them with another representation.

  • 0.5.3
  • PyPI
  • Socket score

Maintainers
1

Welcome to Anchorman

.. image:: https://img.shields.io/pypi/v/anchorman.svg :target: https://pypi.python.org/pypi/anchorman :alt: Latest Version

.. image:: https://travis-ci.org/rebeling/anchorman.svg?branch=master :target: https://travis-ci.org/rebeling/anchorman

Turn your text into hypertext and enrich the content. Anchorman finds terms in text and replaces them with another representation.

The replacement is rule-based. Each term is checked against the rules and will be applied if valid.

# How many items will be marked at all in the text.
replaces_at_all: 5

# Input term has to be exact match in text.
case_sensitive: true

Features

  • replacement rules
  • consider text units in the rules (e.g. paragraphs)
  • replace only n items of the same item
  • specify restricted_areas for linking by tag: a, img
  • sort elements by value before apply them
  • return applied elements

Usage

>>> from anchorman import annotate
>>> text = 'The quick brown fox jumps over the lazy dog.'
>>> elements = [{'fox': {'value': '/wiki/fox', 'data-type': 'animal'}}]
>>> print annotate(text, elements)
'The quick brown <a href="/wiki/fox" data-type="animal">fox</a> jumps over the lazy dog.'

Installation

To install Anchorman, simply:

pip install anchorman

Credits and contributions

We published this at github and pypi to provide our solution to you. Pleased for feedback and contributions.

Thanks @tarnacious for inspiration and first steps.

Todo

  • check if position exist in input and save extra processing
  • html.parser vs lxml in bs4 - benchmarks and drawbacks

Stay tuned.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc