Socket
Socket
Sign inDemoInstall

markdown-it-abbr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-abbr - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

1.0.1 / 2015-12-31
------------------
- Resolved collision with `linkify-it`.
- Extended list of start/stop punctuation characters to unicode ones.
1.0.0 / 2015-03-12

@@ -2,0 +9,0 @@ ------------------

53

index.js

@@ -6,5 +6,11 @@ // Enclose abbreviations in <abbr> tags

var PUNCT_CHARS = ' \n()[]\'".,!?-';
// ASCII characters in Cc, Sc, Sm, Sk categories we should terminate on;
// you can check character classes here:
// http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
var OTHER_CHARS = ' \r\n$+<=>^`|~';
var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex').source;
var UNICODE_SPACE_RE = require('uc.micro/categories/Z/regex').source;
module.exports = function sub_plugin(md) {

@@ -60,3 +66,3 @@ var escapeRE = md.utils.escapeRE,

function abbr_replace(state) {
var i, j, l, tokens, token, text, nodes, pos, reg, m, regText,
var i, j, l, tokens, token, text, nodes, pos, reg, m, regText, regSimple,
currentToken,

@@ -66,14 +72,23 @@ blockTokens = state.tokens;

if (!state.env.abbreviations) { return; }
if (!state.env.abbrRegExp) {
regText = '(^|[' + PUNCT_CHARS.split('').map(escapeRE).join('') + '])'
+ '(' + Object.keys(state.env.abbreviations).map(function (x) {
return x.substr(1);
}).sort(function (a, b) {
return b.length - a.length;
}).map(escapeRE).join('|') + ')'
+ '($|[' + PUNCT_CHARS.split('').map(escapeRE).join('') + '])';
state.env.abbrRegExp = new RegExp(regText, 'g');
}
reg = state.env.abbrRegExp;
regSimple = new RegExp('(?:' +
Object.keys(state.env.abbreviations).map(function (x) {
return x.substr(1);
}).sort(function (a, b) {
return b.length - a.length;
}).map(escapeRE).join('|') +
')');
regText = '(^|' + UNICODE_PUNCT_RE + '|' + UNICODE_SPACE_RE +
'|[' + OTHER_CHARS.split('').map(escapeRE).join('') + '])'
+ '(' + Object.keys(state.env.abbreviations).map(function (x) {
return x.substr(1);
}).sort(function (a, b) {
return b.length - a.length;
}).map(escapeRE).join('|') + ')'
+ '($|' + UNICODE_PUNCT_RE + '|' + UNICODE_SPACE_RE +
'|[' + OTHER_CHARS.split('').map(escapeRE).join('') + '])';
reg = new RegExp(regText, 'g');
for (j = 0, l = blockTokens.length; j < l; j++) {

@@ -93,4 +108,8 @@ if (blockTokens[j].type !== 'inline') { continue; }

// fast regexp run to determine whether there are any abbreviated words
// in the current token
if (!regSimple.test(text)) { continue; }
while ((m = reg.exec(text))) {
if (reg.lastIndex > pos) {
if (m.index > 0 || m[1].length > 0) {
token = new state.Token('text', '', 0);

@@ -112,3 +131,4 @@ token.content = text.slice(pos, m.index + m[1].length);

pos = reg.lastIndex - m[3].length;
reg.lastIndex -= m[3].length;
pos = reg.lastIndex;
}

@@ -131,3 +151,4 @@

md.block.ruler.before('reference', 'abbr_def', abbr_def, { alt: [ 'paragraph', 'reference' ] });
md.core.ruler.after('inline', 'abbr_replace', abbr_replace);
md.core.ruler.after('linkify', 'abbr_replace', abbr_replace);
};
{
"name": "markdown-it-abbr",
"version": "1.0.0",
"version": "1.0.1",
"description": "<abbr> tag for markdown-it markdown parser.",

@@ -36,4 +36,5 @@ "keywords": [

"request": "*",
"uc.micro": "*",
"uglify-js": "*"
}
}
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