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

definition-linker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

definition-linker

Definition linker is a utility to automatically create links to definition URLs, in a given block of text/HTML

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Definition linker

NPM version Dependency Status devDependency Status Build Status

Utility to automatically create links to definition URLs, in a given block of text/HTML.

A stemmer method must be provided to match the words given block of text/HTML with the configured definition words.

Usage

Basic

const natural = require('natural');
const definition_linker = require('definition-linker')({
    stem: function stem(text) {
        // keepStops=true
        return natural.PorterStemmerFr.tokenizeAndStem(text, true).join(' ');
    }
});

definition_linker.createIndex();

definition_linker.addToIndex('node.js', '#node.js');
definition_linker.addToIndex('logiciel libre', '#logiciel-libre');
// etc.

const html = definition_linker.addLinksInHtml('Node.js est un logiciel libre');

Advanced

addLinksInHtml and addLinksInText accept an optional parameter to exclude linking to a specific definition.

const natural = require('natural');
const definition_linker = require('definition-linker')({
    stem: function stem(text) {
        // keepStops=true
        return natural.PorterStemmerFr.tokenizeAndStem(text, true).join(' ');
    }
});

definition_linker.createIndex();

definition_linker.addToIndex('node.js', '#node.js');
definition_linker.addToIndex('logiciel libre', '#logiciel-libre');
// etc.

const html1 = definition_linker.addLinksInHtml('Node.js est un logiciel libre', '#node.js');

const html2 = definition_linker.addLinksInHtml('Il existe de nombreux logiciels libres dont Node.js', '#logiciel-libre');

It is possible to disable linking on some terms in the HTML by setting a "nolink" class:

const natural = require('natural');
const definition_linker = require('definition-linker')({
    stem: function stem(text) {
        // keepStops=true
        return natural.PorterStemmerFr.tokenizeAndStem(text, true).join(' ');
    }
});

definition_linker.createIndex();

definition_linker.addToIndex('node.js', '#node.js');
definition_linker.addToIndex('logiciel libre, '#logiciel-libre');
// etc.

const html3 = definition_linker.addLinksInHtml('Node.js est un <span class="nolink">logiciel libre</span>', '#node.js');

Development

It is possible to disable linking on some terms in the HTML by setting a "nolink" class:

export DEBUG='definition-linker'
npm test

Contributions

Pull Requests and contributions in general are welcome as long as they follow the Node aesthetic.

Keywords

FAQs

Package last updated on 06 Mar 2018

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