Socket
Socket
Sign inDemoInstall

marked-terminal

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-terminal - npm Package Compare versions

Comparing version 3.3.0 to 4.0.0

188

index.js

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -10,3 +10,2 @@ var chalk = require('chalk');

var TABLE_CELL_SPLIT = '^*||*^';

@@ -26,4 +25,4 @@ var TABLE_ROW_WRAP = '*|*|*|*';

var HARD_RETURN = '\r',
HARD_RETURN_RE = new RegExp(HARD_RETURN),
HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');
HARD_RETURN_RE = new RegExp(HARD_RETURN),
HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');

@@ -66,3 +65,3 @@ var defaultOptions = {

this.transform = compose(undoColon, this.unescape, this.emoji);
};
}

@@ -72,4 +71,4 @@ // Compute length of str not including ANSI escape codes.

function textLength(str) {
return str.replace(/\u001b\[(?:\d{1,3})(?:;\d{1,3})*m/g, "").length;
};
return str.replace(/\u001b\[(?:\d{1,3})(?:;\d{1,3})*m/g, '').length;
}

@@ -82,3 +81,3 @@ Renderer.prototype.textLength = textLength;

Renderer.prototype.text = function (text) {
Renderer.prototype.text = function(text) {
return this.o.text(text);

@@ -88,6 +87,5 @@ };

Renderer.prototype.code = function(code, lang, escaped) {
return section(indentify(
this.tab,
highlight(code, lang, this.o, this.highlightOptions)
));
return section(
indentify(this.tab, highlight(code, lang, this.o, this.highlightOptions))
);
};

@@ -106,4 +104,5 @@

var prefix = this.o.showSectionPrefix ?
(new Array(level + 1)).join('#')+' ' : '';
var prefix = this.o.showSectionPrefix
? new Array(level + 1).join('#') + ' '
: '';
text = prefix + text;

@@ -113,3 +112,5 @@ if (this.o.reflowText) {

}
return section(level === 1 ? this.o.firstHeading(text) : this.o.heading(text));
return section(
level === 1 ? this.o.firstHeading(text) : this.o.heading(text)
);
};

@@ -136,3 +137,3 @@

Renderer.prototype.checkbox = function(checked) {
return '[' + (checked ? "X" : " ") + '] ';
return '[' + (checked ? 'X' : ' ') + '] ';
};

@@ -150,7 +151,13 @@

Renderer.prototype.table = function(header, body) {
var table = new Table(Object.assign({}, {
head: generateTableRow(header)[0]
}, this.tableSettings));
var table = new Table(
Object.assign(
{},
{
head: generateTableRow(header)[0]
},
this.tableSettings
)
);
generateTableRow(body, this.transform).forEach(function (row) {
generateTableRow(body, this.transform).forEach(function(row) {
table.push(row);

@@ -211,12 +218,12 @@ });

if (supportsHyperlinks.stdout) {
let link = ''
if(text){
link = this.o.href(this.emoji(text))
}else{
link = this.o.href(href)
let link = '';
if (text) {
link = this.o.href(this.emoji(text));
} else {
link = this.o.href(href);
}
out = ansiEscapes.link(link, href);
}else{
} else {
if (hasText) out += this.emoji(text) + ' (';
out += this.o.href(href);
out += this.o.href(href);
if (hasText) out += ')';

@@ -228,3 +235,6 @@ }

Renderer.prototype.image = function(href, title, text) {
var out = '!['+text;
if (typeof this.o.image === 'function') {
return this.o.image(href, title, text);
}
var out = '![' + text;
if (title) out += ' – ' + title;

@@ -238,10 +248,10 @@ return out + '](' + href + ')\n';

// characters between \n's is less than or equal to "width".
function reflowText (text, width, gfm) {
function reflowText(text, width, gfm) {
// Hard break was inserted by Renderer.prototype.br or is
// <br /> when gfm is true
var splitRe = gfm ? HARD_RETURN_GFM_RE : HARD_RETURN_RE,
sections = text.split(splitRe),
reflowed = [];
sections = text.split(splitRe),
reflowed = [];
sections.forEach(function (section) {
sections.forEach(function(section) {
// Split the section by escape codes so that we can

@@ -281,3 +291,2 @@ // deal with them separately.

if (column + word.length + addSpace > width) {
if (word.length <= width) {

@@ -337,3 +346,3 @@ // If the new word is smaller than the required width

function indentLines (indent, text) {
function indentLines(indent, text) {
return text.replace(/(^|\n)(.+)/g, '$1' + indent + '$2');

@@ -349,30 +358,39 @@ }

var NUMBERED_POINT_REGEX = '\\d+\\.';
var POINT_REGEX = '(?:' + [BULLET_POINT_REGEX, NUMBERED_POINT_REGEX].join('|') + ')';
var POINT_REGEX =
'(?:' + [BULLET_POINT_REGEX, NUMBERED_POINT_REGEX].join('|') + ')';
// Prevents nested lists from joining their parent list's last line
function fixNestedLists (body, indent) {
var regex = new RegExp('' +
function fixNestedLists(body, indent) {
var regex = new RegExp(
'' +
'(\\S(?: | )?)' + // Last char of current point, plus one or two spaces
// to allow trailing spaces
'((?:' + indent + ')+)' + // Indentation of sub point
'(' + POINT_REGEX + '(?:.*)+)$', 'gm'); // Body of subpoint
// to allow trailing spaces
'((?:' +
indent +
')+)' + // Indentation of sub point
'(' +
POINT_REGEX +
'(?:.*)+)$',
'gm'
); // Body of subpoint
return body.replace(regex, '$1\n' + indent + '$2$3');
}
var isPointedLine = function (line, indent) {
var isPointedLine = function(line, indent) {
return line.match('^(?:' + indent + ')*' + POINT_REGEX);
}
};
function toSpaces (str) {
return (' ').repeat(str.length);
function toSpaces(str) {
return ' '.repeat(str.length);
}
var BULLET_POINT = '* ';
function bulletPointLine (indent, line) {
function bulletPointLine(indent, line) {
return isPointedLine(line, indent) ? line : toSpaces(BULLET_POINT) + line;
}
function bulletPointLines (lines, indent) {
function bulletPointLines(lines, indent) {
var transform = bulletPointLine.bind(null, indent);
return lines.split('\n')
return lines
.split('\n')
.filter(identity)

@@ -383,22 +401,24 @@ .map(transform)

var numberedPoint = function (n) {
return n + '. ';
var numberedPoint = function(n) {
return n + '. ';
};
function numberedLine (indent, line, num) {
return isPointedLine(line, indent) ? {
num: num+1,
line: line.replace(BULLET_POINT, numberedPoint(num+1))
} : {
num: num,
line: toSpaces(numberedPoint(num)) + line
};
function numberedLine(indent, line, num) {
return isPointedLine(line, indent)
? {
num: num + 1,
line: line.replace(BULLET_POINT, numberedPoint(num + 1))
}
: {
num: num,
line: toSpaces(numberedPoint(num)) + line
};
}
function numberedLines (lines, indent) {
function numberedLines(lines, indent) {
var transform = numberedLine.bind(null, indent);
let num = 0;
return lines.split('\n')
return lines
.split('\n')
.filter(identity)
.map((line) => {
.map(line => {
const numbered = transform(line, num);

@@ -418,3 +438,3 @@ num = numbered.num;

function section (text) {
function section(text) {
return text + '\n\n';

@@ -424,3 +444,3 @@ }

function highlight(code, lang, opts, hightlightOpts) {
if (!chalk.enabled) return code;
if (chalk.level === 0) return code;

@@ -442,3 +462,3 @@ var style = opts.code;

function insertEmojis(text) {
return text.replace(/:([A-Za-z0-9_\-\+]+?):/g, function (emojiString) {
return text.replace(/:([A-Za-z0-9_\-\+]+?):/g, function(emojiString) {
var emojiSign = emoji.get(emojiString);

@@ -452,6 +472,6 @@ if (!emojiSign) return emojiString;

length = length || process.stdout.columns;
return (new Array(length)).join(inputHrStr);
return new Array(length).join(inputHrStr);
}
function undoColon (str) {
function undoColon(str) {
return str.replace(COLON_REPLACER_REGEXP, ':');

@@ -466,5 +486,7 @@ }

var data = [];
lines.forEach(function (line) {
lines.forEach(function(line) {
if (!line) return;
var parsed = line.replace(TABLE_ROW_WRAP_REGEXP, '').split(TABLE_CELL_SPLIT);
var parsed = line
.replace(TABLE_ROW_WRAP_REGEXP, '')
.split(TABLE_CELL_SPLIT);

@@ -477,3 +499,3 @@ data.push(parsed.splice(0, parsed.length - 1));

function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}

@@ -483,18 +505,18 @@

return html
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'");
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'");
}
function identity (str) {
function identity(str) {
return str;
}
function compose () {
function compose() {
var funcs = arguments;
return function() {
var args = arguments;
for (var i = funcs.length; i-- > 0;) {
for (var i = funcs.length; i-- > 0; ) {
args = [funcs[i].apply(this, args)];

@@ -506,16 +528,16 @@ }

function isAllowedTabString (string) {
return TAB_ALLOWED_CHARACTERS.some(function (char) {
return string.match('^('+char+')+$');
function isAllowedTabString(string) {
return TAB_ALLOWED_CHARACTERS.some(function(char) {
return string.match('^(' + char + ')+$');
});
}
function sanitizeTab (tab, fallbackTab) {
function sanitizeTab(tab, fallbackTab) {
if (typeof tab === 'number') {
return (new Array(tab + 1)).join(' ');
return new Array(tab + 1).join(' ');
} else if (typeof tab === 'string' && isAllowedTabString(tab)) {
return tab;
} else {
return (new Array(fallbackTab + 1)).join(' ');
return new Array(fallbackTab + 1).join(' ');
}
}
{
"name": "marked-terminal",
"version": "3.3.0",
"version": "4.0.0",
"description": "A custom render for marked to output to the Terminal",

@@ -22,11 +22,11 @@ "main": "index.js",

"peerDependencies": {
"marked": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0"
"marked": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0"
},
"dependencies": {
"ansi-escapes": "^3.1.0",
"ansi-escapes": "^4.3.0",
"cardinal": "^2.1.1",
"chalk": "^2.4.1",
"chalk": "^3.0.0",
"cli-table": "^0.3.1",
"node-emoji": "^1.4.1",
"supports-hyperlinks": "^1.0.1"
"node-emoji": "^1.10.0",
"supports-hyperlinks": "^2.0.0"
},

@@ -37,4 +37,4 @@ "directories": {

"devDependencies": {
"marked": "^0.7.0",
"mocha": "^5.2.0"
"marked": "^0.8.0",
"mocha": "^7.0.0"
},

@@ -41,0 +41,0 @@ "repository": {

@@ -117,2 +117,4 @@ marked-terminal

tab: 3 // examples: 4, 2, \t, \t\t
image: function (href, title, text) {} // function for overriding the default image handling.
};

@@ -119,0 +121,0 @@ ```

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