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

@vscode/markdown-it-katex

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vscode/markdown-it-katex - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

99

dist/index.js

@@ -169,9 +169,11 @@ "use strict";

function blockBareMath(state, start, end, silent) {
var lastLine, found = false, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start];
const firstLine = state.src.slice(pos, max);
if (!/^\s*\\begin/.test(firstLine)) {
const startPos = state.bMarks[start] + state.tShift[start];
const startMax = state.eMarks[start];
const firstLine = state.src.slice(startPos, startMax);
const beginMatch = firstLine.match(/^\s*\\begin\s*\{([^{}]+)\}/);
if (!beginMatch) {
return false;
}
if (start > 0) {
// Previous line must be blank for bare blocks
// Previous line must be blank for bare blocks. There are instead handled by inlineBareBlock
const previousStart = state.bMarks[start - 1] + state.tShift[start - 1];

@@ -187,30 +189,28 @@ const previousEnd = state.eMarks[start - 1];

}
// Handle Single line code block
const beginEndStack = [];
let next = start;
if (!/\\end[\{\}\w]*\s*$/.test(firstLine)) {
let nestingCount = 0;
for (; !found;) {
next++;
if (next >= end) {
break;
let lastLine;
let found = false;
outer: for (; !found; next++) {
if (next >= end) {
break;
}
const pos = state.bMarks[next] + state.tShift[next];
const max = state.eMarks[next];
if (pos < max && state.tShift[next] < state.blkIndent) {
// non-empty line with negative indent should stop the list:
break;
}
const line = state.src.slice(pos, max);
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
if (match[1] === '\\begin') {
beginEndStack.push(match[2].trim());
}
pos = state.bMarks[next] + state.tShift[next];
max = state.eMarks[next];
if (pos < max && state.tShift[next] < state.blkIndent) {
// non-empty line with negative indent should stop the list:
break;
}
const line = state.src.slice(pos, max);
for (const match of line.matchAll(/\\begin|\\end/g)) {
if (match[0] === '\\begin') {
++nestingCount;
else if (match[1] === '\\end') {
beginEndStack.pop();
if (!beginEndStack.length) {
lastLine = state.src.slice(pos, max);
found = true;
break outer;
}
else if (match[0] === '\\end') {
--nestingCount;
if (nestingCount < 0) {
const lastPos = max;
lastLine = state.src.slice(pos, lastPos);
found = true;
}
}
}

@@ -222,5 +222,3 @@ }

token.block = true;
token.content = (firstLine && firstLine.trim() ? firstLine + '\n' : '')
+ state.getLines(start + 1, next, state.tShift[start], true)
+ (lastLine && lastLine.trim() ? lastLine : '');
token.content = (state.getLines(start, next, state.tShift[start], true) + (lastLine ?? '')).trim();
token.map = [start, state.line];

@@ -298,2 +296,3 @@ token.markup = '$$';

const text = state.src.slice(state.pos);
// Make sure this is not a normal bare block
if (!/^\n\\begin/.test(text)) {

@@ -307,17 +306,17 @@ return false;

const lines = text.split(/\n/g).slice(1);
const beginRe = /^\\begin/;
const endRe = /^\\end/;
let nestingCount = 0;
let foundLine = undefined;
for (var i = 0; i < lines.length; ++i) {
let foundLine;
const beginEndStack = [];
outer: for (var i = 0; i < lines.length; ++i) {
const line = lines[i];
if (beginRe.test(line)) {
++nestingCount;
}
else if (endRe.test(line)) {
--nestingCount;
if (nestingCount <= 0) {
foundLine = i;
break;
for (const match of line.matchAll(/(\\begin|\\end)\s*\{([^{}]+)\}/g)) {
if (match[1] === '\\begin') {
beginEndStack.push(match[2].trim());
}
else if (match[1] === '\\end') {
beginEndStack.pop();
if (!beginEndStack.length) {
foundLine = i;
break outer;
}
}
}

@@ -329,8 +328,6 @@ }

const endIndex = lines.slice(0, foundLine + 1).reduce((p, c) => p + c.length, 0) + foundLine + 1;
if (!silent) {
const token = state.push('math_inline_bare_block', 'math', 0);
token.block = true;
token.markup = "$$";
token.content = text.slice(1, endIndex);
}
const token = state.push('math_inline_bare_block', 'math', 0);
token.block = true;
token.markup = "$$";
token.content = text.slice(1, endIndex);
state.pos = state.pos + endIndex;

@@ -337,0 +334,0 @@ return true;

{
"name": "@vscode/markdown-it-katex",
"version": "1.0.2",
"version": "1.0.3",
"description": "Markdown-it plugin that provides VS Code's KaTeX support",

@@ -5,0 +5,0 @@ "main": "dist/index.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