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

markdown-it

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it - npm Package Compare versions

Comparing version 12.2.0 to 12.3.0

6

lib/renderer.js

@@ -260,3 +260,3 @@ /**

* Renderer.renderInline(tokens, options, env) -> String
* - tokens (Array): list on block tokens to renter
* - tokens (Array): list on block tokens to render
* - options (Object): params of parser instance

@@ -288,3 +288,3 @@ * - env (Object): additional data from parsed input (references, for example)

* Renderer.renderInlineAsText(tokens, options, env) -> String
* - tokens (Array): list on block tokens to renter
* - tokens (Array): list on block tokens to render
* - options (Object): params of parser instance

@@ -316,3 +316,3 @@ * - env (Object): additional data from parsed input (references, for example)

* Renderer.render(tokens, options, env) -> String
* - tokens (Array): list on block tokens to renter
* - tokens (Array): list on block tokens to render
* - options (Object): params of parser instance

@@ -319,0 +319,0 @@ * - env (Object): additional data from parsed input (references, for example)

@@ -12,5 +12,24 @@ // For each opening emphasis-like marker find a matching closing one

if (!max) return;
// headerIdx is the first delimiter of the current (where closer is) delimiter run
var headerIdx = 0;
var lastTokenIdx = -2; // needs any value lower than -1
var jumps = [];
for (closerIdx = 0; closerIdx < max; closerIdx++) {
closer = delimiters[closerIdx];
jumps.push(0);
// markers belong to same delimiter run if:
// - they have adjacent tokens
// - AND markers are the same
//
if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
headerIdx = closerIdx;
}
lastTokenIdx = closer.token;
// Length is only used for emphasis-specific "rule of 3",

@@ -34,10 +53,7 @@ // if it's not defined (in strikethrough or 3rd party plugins),

openerIdx = closerIdx - closer.jump - 1;
openerIdx = headerIdx - jumps[headerIdx] - 1;
// avoid crash if `closer.jump` is pointing outside of the array, see #742
if (openerIdx < -1) openerIdx = -1;
newMinOpenerIdx = openerIdx;
for (; openerIdx > minOpenerIdx; openerIdx -= opener.jump + 1) {
for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
opener = delimiters[openerIdx];

@@ -72,11 +88,15 @@

lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?
delimiters[openerIdx - 1].jump + 1 :
jumps[openerIdx - 1] + 1 :
0;
closer.jump = closerIdx - openerIdx + lastJump;
jumps[closerIdx] = closerIdx - openerIdx + lastJump;
jumps[openerIdx] = lastJump;
closer.open = false;
opener.end = closerIdx;
opener.jump = lastJump;
opener.close = false;
newMinOpenerIdx = -1;
// treat next token as start of run,
// it optimizes skips in **<...>**a**<...>** pathological case
lastTokenIdx = -2;
break;

@@ -83,0 +103,0 @@ }

@@ -32,11 +32,2 @@ // Process *this* and _that_

// An amount of characters before this one that's equivalent to
// current one. In plain English: if this delimiter does not open
// an emphasis, neither do previous `jump` characters.
//
// Used to skip sequences like "*****" in one step, for 1st asterisk
// value will be 0, for 2nd it's 1 and so on.
//
jump: i,
// A position of the token this delimiter corresponds to.

@@ -95,5 +86,7 @@ //

delimiters[i - 1].end === startDelim.end + 1 &&
// check that first two markers match and adjacent
delimiters[i - 1].marker === startDelim.marker &&
delimiters[i - 1].token === startDelim.token - 1 &&
delimiters[startDelim.end + 1].token === endDelim.token + 1 &&
delimiters[i - 1].marker === startDelim.marker;
// check that last two markers are adjacent (we can safely assume they match)
delimiters[startDelim.end + 1].token === endDelim.token + 1;

@@ -100,0 +93,0 @@ ch = String.fromCharCode(startDelim.marker);

@@ -36,3 +36,2 @@ // ~~strike through~~

length: 0, // disable "rule of 3" length checks meant for emphasis
jump: i / 2, // for `~~` 1 marker = 2 characters
token: state.tokens.length - 1,

@@ -39,0 +38,0 @@ end: -1,

{
"name": "markdown-it",
"version": "12.2.0",
"version": "12.3.0",
"description": "Markdown-it - modern pluggable markdown parser.",

@@ -55,3 +55,3 @@ "keywords": [

"coveralls": "^3.0.4",
"eslint": "^7.0.0",
"eslint": "^8.4.1",
"express": "^4.14.0",

@@ -72,5 +72,5 @@ "gh-pages": "^3.1.0",

"markdown-it-testgen": "^0.1.3",
"mocha": "^8.0.1",
"mocha": "^9.1.3",
"ndoc": "^6.0.0",
"needle": "^2.5.2",
"needle": "^3.0.0",
"nyc": "^15.0.1",

@@ -82,3 +82,3 @@ "pug-cli": "^1.0.0-alpha6",

"shelljs": "^0.8.4",
"stylus": "^0.54.5",
"stylus": "^0.55.0",
"supertest": "^6.0.1"

@@ -85,0 +85,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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