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

marked-terminal

Package Overview
Dependencies
Maintainers
1
Versions
36
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 2.0.0 to 3.0.0

LICENSE

125

index.js

@@ -120,3 +120,5 @@ "use strict";

if (isNested) text = text.trim();
return '\n' + transform(text);
// Use BULLET_POINT as a marker for ordered or unordered list item
return '\n' + BULLET_POINT + transform(text);
};

@@ -217,20 +219,88 @@

sections.forEach(function (section) {
var words = section.split(/[ \t\n]+/),
column = 0,
nextText = '';
// Split the section by escape codes so that we can
// deal with them separately.
var fragments = section.split(/(\u001b\[(?:\d{1,3})(?:;\d{1,3})*m)/g);
var column = 0;
var currentLine = '';
var lastWasEscapeChar = false;
words.forEach(function (word) {
var addOne = column != 0;
if ((column + textLength(word) + addOne) > width) {
nextText += '\n';
column = 0;
} else if (addOne) {
nextText += " ";
column += 1;
while (fragments.length) {
var fragment = fragments[0];
if (fragment === '') {
fragments.splice(0, 1);
lastWasEscapeChar = false;
continue;
}
nextText += word;
column += textLength(word);
});
reflowed.push(nextText);
// This is an escape code - leave it whole and
// move to the next fragment.
if (!textLength(fragment)) {
currentLine += fragment;
fragments.splice(0, 1);
lastWasEscapeChar = true;
continue;
}
var words = fragment.split(/[ \t\n]+/);
for (var i = 0; i < words.length; i++) {
var word = words[i];
var addSpace = column != 0;
if (lastWasEscapeChar) addSpace = false;
// If adding the new word overflows the required width
if (column + word.length + addSpace > width) {
if (word.length <= width) {
// If the new word is smaller than the required width
// just add it at the beginning of a new line
reflowed.push(currentLine);
currentLine = word;
column = word.length;
} else {
// If the new word is longer than the required width
// split this word into smaller parts.
var w = word.substr(0, width - column - addSpace);
if (addSpace) currentLine += ' ';
currentLine += w;
reflowed.push(currentLine);
currentLine = '';
column = 0;
word = word.substr(w.length);
while (word.length) {
var w = word.substr(0, width);
if (!w.length) break;
if (w.length < width) {
currentLine = w;
column = w.length;
break;
} else {
reflowed.push(w);
word = word.substr(width);
}
}
}
} else {
if (addSpace) {
currentLine += ' ';
column++;
}
currentLine += word;
column += word.length;
}
lastWasEscapeChar = false;
}
fragments.splice(0, 1);
}
if (textLength(currentLine)) reflowed.push(currentLine);
});
return reflowed.join('\n');

@@ -266,5 +336,9 @@ }

function toSpaces (str) {
return (' ').repeat(str.length);
}
var BULLET_POINT = '* ';
function bulletPointLine (indent, line) {
return isPointedLine(line, indent) ? line : BULLET_POINT + line;
return isPointedLine(line, indent) ? line : toSpaces(BULLET_POINT) + line;
}

@@ -284,3 +358,9 @@

function numberedLine (indent, line, num) {
return isPointedLine(line, indent) ? line : (numberedPoint(num+1) + line);
return isPointedLine(line, indent) ? {
num: num+1,
line: line.replace(BULLET_POINT, numberedPoint(num+1))
} : {
num: num,
line: toSpaces(numberedPoint(num)) + line
};
}

@@ -290,5 +370,12 @@

var transform = numberedLine.bind(null, indent);
let num = 0;
return lines.split('\n')
.filter(identity)
.map(transform)
.map((line) => {
const numbered = transform(line, num);
num = numbered.num;
return numbered.line;
})
.join('\n');

@@ -295,0 +382,0 @@ }

6

package.json
{
"name": "marked-terminal",
"version": "2.0.0",
"version": "3.0.0",
"description": "A custom render for marked to output to the Terminal",

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

"peerDependencies": {
"marked": "^0.3.6"
"marked": "^0.4.0"
},

@@ -36,3 +36,3 @@ "dependencies": {

"devDependencies": {
"marked": "^0.3.6",
"marked": "^0.4.0",
"mocha": "^3.1.2"

@@ -39,0 +39,0 @@ },

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

[![Build Status](https://img.shields.io/travis/mikaelbr/marked-terminal.svg)](https://travis-ci.org/mikaelbr/marked-terminal) [![npm marked-terminal](https://img.shields.io/npm/v/marked-terminal.svg)](https://www.npmjs.com/package/marked-terminal)
## Install

@@ -12,0 +14,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