Socket
Socket
Sign inDemoInstall

turndown

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turndown - npm Package Compare versions

Comparing version 0.0.6 to 0.0.8

74

dist/turndown.js

@@ -244,4 +244,13 @@ var TurndownService = (function () {

replacement: function (content) {
var delimiter = /`/.test(content) ? '``' : '`';
return delimiter + content + delimiter
var delimiter = '`';
var leadingSpace = '';
var trailingSpace = '';
var matches = content.match(/`+/gm);
if (matches) {
if (/^`/.test(content)) leadingSpace = ' ';
if (/`$/.test(content)) trailingSpace = ' ';
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';
}
return delimiter + leadingSpace + content + trailingSpace + delimiter
}

@@ -655,2 +664,3 @@ };

node.isVoid = isVoid$1(node);
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;
node.isBlank = isBlank(node);

@@ -759,3 +769,3 @@ node.flankingWhitespace = flankingWhitespace(node);

this.options.keepConverter = this.options.keepConverter || {
this.options.keepRule = this.options.keepRule || {
filter: this.options.keep,

@@ -767,3 +777,3 @@ replacement: function (content, node) {

this.options.removeConverter = this.options.removeConverter || {
this.options.removeRule = this.options.removeRule || {
filter: this.options.remove,

@@ -810,4 +820,4 @@ replacement: function () {

process: function process (parentNode) {
var _this = this;
process: function (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {

@@ -818,5 +828,5 @@ node = new Node(node);

if (node.nodeType === 3) {
replacement = _this.escape(node.nodeValue);
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = _this.replacementForNode(node);
replacement = self.replacementForNode(node);
}

@@ -832,5 +842,11 @@

escape: function escape (string) {
escape: function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr

@@ -852,24 +868,14 @@ .replace(/^([-*_] *){3,}$/gm, function (match, character) {

// Escape strong *
.replace(/[^\\]\*\*[^*\s.].+?[^\s]\*\*/g, function (match) {
// Escape em/strong *
.replace(/\*+(?![*\s\W]).+?\*+/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape em *
.replace(/[^\\]\*[^*\s.].+?[^\s]\*/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape strong _
.replace(/[^\\]__[^_\s.].+?[^\s]__/g, function (match) {
// Escape em/strong _
.replace(/_+(?![_\s\W]).+?_+/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape em _
.replace(/[^\\]_[^_\s.].+?[^\s]_/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape `
.replace(/[^\\]`[^`\s.].+?`/g, function (match) {
// Escape code _
.replace(/`+(?![`\s\W]).+?`+/g, function (match) {
return match.replace(/`/g, '\\`')

@@ -879,3 +885,3 @@ })

// Escape link brackets
.replace(/\[([^\]]*)\]/g, '\\[$1\\]') // eslint-disable-line no-useless-escape
.replace(/[\[\]]/g, '\\$&') // eslint-disable-line no-useless-escape
)

@@ -888,3 +894,3 @@ },

replacementForNode: function replacementForNode (node) {
replacementForNode: function (node) {
var rule = this.ruleForNode(node);

@@ -905,9 +911,9 @@ var content = this.process(node);

ruleForNode: function ruleForNode (node) {
if (this.filterValue(this.options.keepConverter, node)) {
return this.options.keepConverter
ruleForNode: function (node) {
if (this.filterValue(this.options.keepRule, node)) {
return this.options.keepRule
}
if (this.filterValue(this.options.removeConverter, node)) {
return this.options.removeConverter
if (this.filterValue(this.options.removeRule, node)) {
return this.options.removeRule
}

@@ -925,3 +931,3 @@

filterValue: function filterValue (rule, node) {
filterValue: function (rule, node) {
var filter = rule.filter;

@@ -939,3 +945,3 @@ if (typeof filter === 'string') {

postProcess: function postProcess (output) {
postProcess: function (output) {
for (var key in this.options.rules) {

@@ -942,0 +948,0 @@ var rule = this.options.rules[key];

@@ -243,4 +243,13 @@ 'use strict';

replacement: function (content) {
var delimiter = /`/.test(content) ? '``' : '`';
return delimiter + content + delimiter
var delimiter = '`';
var leadingSpace = '';
var trailingSpace = '';
var matches = content.match(/`+/gm);
if (matches) {
if (/^`/.test(content)) leadingSpace = ' ';
if (/`$/.test(content)) trailingSpace = ' ';
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';
}
return delimiter + leadingSpace + content + trailingSpace + delimiter
}

@@ -654,2 +663,3 @@ };

node.isVoid = isVoid$1(node);
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;
node.isBlank = isBlank(node);

@@ -758,3 +768,3 @@ node.flankingWhitespace = flankingWhitespace(node);

this.options.keepConverter = this.options.keepConverter || {
this.options.keepRule = this.options.keepRule || {
filter: this.options.keep,

@@ -766,3 +776,3 @@ replacement: function (content, node) {

this.options.removeConverter = this.options.removeConverter || {
this.options.removeRule = this.options.removeRule || {
filter: this.options.remove,

@@ -809,4 +819,4 @@ replacement: function () {

process: function process (parentNode) {
var _this = this;
process: function (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {

@@ -817,5 +827,5 @@ node = new Node(node);

if (node.nodeType === 3) {
replacement = _this.escape(node.nodeValue);
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = _this.replacementForNode(node);
replacement = self.replacementForNode(node);
}

@@ -831,5 +841,11 @@

escape: function escape (string) {
escape: function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr

@@ -851,24 +867,14 @@ .replace(/^([-*_] *){3,}$/gm, function (match, character) {

// Escape strong *
.replace(/[^\\]\*\*[^*\s.].+?[^\s]\*\*/g, function (match) {
// Escape em/strong *
.replace(/\*+(?![*\s\W]).+?\*+/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape em *
.replace(/[^\\]\*[^*\s.].+?[^\s]\*/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape strong _
.replace(/[^\\]__[^_\s.].+?[^\s]__/g, function (match) {
// Escape em/strong _
.replace(/_+(?![_\s\W]).+?_+/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape em _
.replace(/[^\\]_[^_\s.].+?[^\s]_/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape `
.replace(/[^\\]`[^`\s.].+?`/g, function (match) {
// Escape code _
.replace(/`+(?![`\s\W]).+?`+/g, function (match) {
return match.replace(/`/g, '\\`')

@@ -878,3 +884,3 @@ })

// Escape link brackets
.replace(/\[([^\]]*)\]/g, '\\[$1\\]') // eslint-disable-line no-useless-escape
.replace(/[\[\]]/g, '\\$&') // eslint-disable-line no-useless-escape
)

@@ -887,3 +893,3 @@ },

replacementForNode: function replacementForNode (node) {
replacementForNode: function (node) {
var rule = this.ruleForNode(node);

@@ -904,9 +910,9 @@ var content = this.process(node);

ruleForNode: function ruleForNode (node) {
if (this.filterValue(this.options.keepConverter, node)) {
return this.options.keepConverter
ruleForNode: function (node) {
if (this.filterValue(this.options.keepRule, node)) {
return this.options.keepRule
}
if (this.filterValue(this.options.removeConverter, node)) {
return this.options.removeConverter
if (this.filterValue(this.options.removeRule, node)) {
return this.options.removeRule
}

@@ -924,3 +930,3 @@

filterValue: function filterValue (rule, node) {
filterValue: function (rule, node) {
var filter = rule.filter;

@@ -938,3 +944,3 @@ if (typeof filter === 'string') {

postProcess: function postProcess (output) {
postProcess: function (output) {
for (var key in this.options.rules) {

@@ -941,0 +947,0 @@ var rule = this.options.rules[key];

@@ -241,4 +241,13 @@ function extend (destination) {

replacement: function (content) {
var delimiter = /`/.test(content) ? '``' : '`';
return delimiter + content + delimiter
var delimiter = '`';
var leadingSpace = '';
var trailingSpace = '';
var matches = content.match(/`+/gm);
if (matches) {
if (/^`/.test(content)) leadingSpace = ' ';
if (/`$/.test(content)) trailingSpace = ' ';
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';
}
return delimiter + leadingSpace + content + trailingSpace + delimiter
}

@@ -652,2 +661,3 @@ };

node.isVoid = isVoid$1(node);
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;
node.isBlank = isBlank(node);

@@ -756,3 +766,3 @@ node.flankingWhitespace = flankingWhitespace(node);

this.options.keepConverter = this.options.keepConverter || {
this.options.keepRule = this.options.keepRule || {
filter: this.options.keep,

@@ -764,3 +774,3 @@ replacement: function (content, node) {

this.options.removeConverter = this.options.removeConverter || {
this.options.removeRule = this.options.removeRule || {
filter: this.options.remove,

@@ -807,4 +817,4 @@ replacement: function () {

process: function process (parentNode) {
var _this = this;
process: function (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {

@@ -815,5 +825,5 @@ node = new Node(node);

if (node.nodeType === 3) {
replacement = _this.escape(node.nodeValue);
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = _this.replacementForNode(node);
replacement = self.replacementForNode(node);
}

@@ -829,5 +839,11 @@

escape: function escape (string) {
escape: function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr

@@ -849,24 +865,14 @@ .replace(/^([-*_] *){3,}$/gm, function (match, character) {

// Escape strong *
.replace(/[^\\]\*\*[^*\s.].+?[^\s]\*\*/g, function (match) {
// Escape em/strong *
.replace(/\*+(?![*\s\W]).+?\*+/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape em *
.replace(/[^\\]\*[^*\s.].+?[^\s]\*/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape strong _
.replace(/[^\\]__[^_\s.].+?[^\s]__/g, function (match) {
// Escape em/strong _
.replace(/_+(?![_\s\W]).+?_+/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape em _
.replace(/[^\\]_[^_\s.].+?[^\s]_/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape `
.replace(/[^\\]`[^`\s.].+?`/g, function (match) {
// Escape code _
.replace(/`+(?![`\s\W]).+?`+/g, function (match) {
return match.replace(/`/g, '\\`')

@@ -876,3 +882,3 @@ })

// Escape link brackets
.replace(/\[([^\]]*)\]/g, '\\[$1\\]') // eslint-disable-line no-useless-escape
.replace(/[\[\]]/g, '\\$&') // eslint-disable-line no-useless-escape
)

@@ -885,3 +891,3 @@ },

replacementForNode: function replacementForNode (node) {
replacementForNode: function (node) {
var rule = this.ruleForNode(node);

@@ -902,9 +908,9 @@ var content = this.process(node);

ruleForNode: function ruleForNode (node) {
if (this.filterValue(this.options.keepConverter, node)) {
return this.options.keepConverter
ruleForNode: function (node) {
if (this.filterValue(this.options.keepRule, node)) {
return this.options.keepRule
}
if (this.filterValue(this.options.removeConverter, node)) {
return this.options.removeConverter
if (this.filterValue(this.options.removeRule, node)) {
return this.options.removeRule
}

@@ -922,3 +928,3 @@

filterValue: function filterValue (rule, node) {
filterValue: function (rule, node) {
var filter = rule.filter;

@@ -936,3 +942,3 @@ if (typeof filter === 'string') {

postProcess: function postProcess (output) {
postProcess: function (output) {
for (var key in this.options.rules) {

@@ -939,0 +945,0 @@ var rule = this.options.rules[key];

@@ -243,4 +243,13 @@ 'use strict';

replacement: function (content) {
var delimiter = /`/.test(content) ? '``' : '`';
return delimiter + content + delimiter
var delimiter = '`';
var leadingSpace = '';
var trailingSpace = '';
var matches = content.match(/`+/gm);
if (matches) {
if (/^`/.test(content)) leadingSpace = ' ';
if (/`$/.test(content)) trailingSpace = ' ';
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';
}
return delimiter + leadingSpace + content + trailingSpace + delimiter
}

@@ -654,2 +663,3 @@ };

node.isVoid = isVoid$1(node);
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;
node.isBlank = isBlank(node);

@@ -758,3 +768,3 @@ node.flankingWhitespace = flankingWhitespace(node);

this.options.keepConverter = this.options.keepConverter || {
this.options.keepRule = this.options.keepRule || {
filter: this.options.keep,

@@ -766,3 +776,3 @@ replacement: function (content, node) {

this.options.removeConverter = this.options.removeConverter || {
this.options.removeRule = this.options.removeRule || {
filter: this.options.remove,

@@ -809,4 +819,4 @@ replacement: function () {

process: function process (parentNode) {
var _this = this;
process: function (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {

@@ -817,5 +827,5 @@ node = new Node(node);

if (node.nodeType === 3) {
replacement = _this.escape(node.nodeValue);
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = _this.replacementForNode(node);
replacement = self.replacementForNode(node);
}

@@ -831,5 +841,11 @@

escape: function escape (string) {
escape: function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr

@@ -851,24 +867,14 @@ .replace(/^([-*_] *){3,}$/gm, function (match, character) {

// Escape strong *
.replace(/[^\\]\*\*[^*\s.].+?[^\s]\*\*/g, function (match) {
// Escape em/strong *
.replace(/\*+(?![*\s\W]).+?\*+/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape em *
.replace(/[^\\]\*[^*\s.].+?[^\s]\*/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape strong _
.replace(/[^\\]__[^_\s.].+?[^\s]__/g, function (match) {
// Escape em/strong _
.replace(/_+(?![_\s\W]).+?_+/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape em _
.replace(/[^\\]_[^_\s.].+?[^\s]_/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape `
.replace(/[^\\]`[^`\s.].+?`/g, function (match) {
// Escape code _
.replace(/`+(?![`\s\W]).+?`+/g, function (match) {
return match.replace(/`/g, '\\`')

@@ -878,3 +884,3 @@ })

// Escape link brackets
.replace(/\[([^\]]*)\]/g, '\\[$1\\]') // eslint-disable-line no-useless-escape
.replace(/[\[\]]/g, '\\$&') // eslint-disable-line no-useless-escape
)

@@ -887,3 +893,3 @@ },

replacementForNode: function replacementForNode (node) {
replacementForNode: function (node) {
var rule = this.ruleForNode(node);

@@ -904,9 +910,9 @@ var content = this.process(node);

ruleForNode: function ruleForNode (node) {
if (this.filterValue(this.options.keepConverter, node)) {
return this.options.keepConverter
ruleForNode: function (node) {
if (this.filterValue(this.options.keepRule, node)) {
return this.options.keepRule
}
if (this.filterValue(this.options.removeConverter, node)) {
return this.options.removeConverter
if (this.filterValue(this.options.removeRule, node)) {
return this.options.removeRule
}

@@ -924,3 +930,3 @@

filterValue: function filterValue (rule, node) {
filterValue: function (rule, node) {
var filter = rule.filter;

@@ -938,3 +944,3 @@ if (typeof filter === 'string') {

postProcess: function postProcess (output) {
postProcess: function (output) {
for (var key in this.options.rules) {

@@ -941,0 +947,0 @@ var rule = this.options.rules[key];

@@ -241,4 +241,13 @@ function extend (destination) {

replacement: function (content) {
var delimiter = /`/.test(content) ? '``' : '`';
return delimiter + content + delimiter
var delimiter = '`';
var leadingSpace = '';
var trailingSpace = '';
var matches = content.match(/`+/gm);
if (matches) {
if (/^`/.test(content)) leadingSpace = ' ';
if (/`$/.test(content)) trailingSpace = ' ';
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';
}
return delimiter + leadingSpace + content + trailingSpace + delimiter
}

@@ -652,2 +661,3 @@ };

node.isVoid = isVoid$1(node);
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;
node.isBlank = isBlank(node);

@@ -756,3 +766,3 @@ node.flankingWhitespace = flankingWhitespace(node);

this.options.keepConverter = this.options.keepConverter || {
this.options.keepRule = this.options.keepRule || {
filter: this.options.keep,

@@ -764,3 +774,3 @@ replacement: function (content, node) {

this.options.removeConverter = this.options.removeConverter || {
this.options.removeRule = this.options.removeRule || {
filter: this.options.remove,

@@ -807,4 +817,4 @@ replacement: function () {

process: function process (parentNode) {
var _this = this;
process: function (parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function (output, node) {

@@ -815,5 +825,5 @@ node = new Node(node);

if (node.nodeType === 3) {
replacement = _this.escape(node.nodeValue);
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = _this.replacementForNode(node);
replacement = self.replacementForNode(node);
}

@@ -829,5 +839,11 @@

escape: function escape (string) {
escape: function (string) {
return (
string
// Escape backslash escapes!
.replace(/\\(\S)/g, '\\\\$1')
// Escape headings
.replace(/^(#{1,6} )/gm, '\\$1')
// Escape hr

@@ -849,24 +865,14 @@ .replace(/^([-*_] *){3,}$/gm, function (match, character) {

// Escape strong *
.replace(/[^\\]\*\*[^*\s.].+?[^\s]\*\*/g, function (match) {
// Escape em/strong *
.replace(/\*+(?![*\s\W]).+?\*+/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape em *
.replace(/[^\\]\*[^*\s.].+?[^\s]\*/g, function (match) {
return match.replace(/\*/g, '\\*')
})
// Escape strong _
.replace(/[^\\]__[^_\s.].+?[^\s]__/g, function (match) {
// Escape em/strong _
.replace(/_+(?![_\s\W]).+?_+/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape em _
.replace(/[^\\]_[^_\s.].+?[^\s]_/g, function (match) {
return match.replace(/_/g, '\\_')
})
// Escape `
.replace(/[^\\]`[^`\s.].+?`/g, function (match) {
// Escape code _
.replace(/`+(?![`\s\W]).+?`+/g, function (match) {
return match.replace(/`/g, '\\`')

@@ -876,3 +882,3 @@ })

// Escape link brackets
.replace(/\[([^\]]*)\]/g, '\\[$1\\]') // eslint-disable-line no-useless-escape
.replace(/[\[\]]/g, '\\$&') // eslint-disable-line no-useless-escape
)

@@ -885,3 +891,3 @@ },

replacementForNode: function replacementForNode (node) {
replacementForNode: function (node) {
var rule = this.ruleForNode(node);

@@ -902,9 +908,9 @@ var content = this.process(node);

ruleForNode: function ruleForNode (node) {
if (this.filterValue(this.options.keepConverter, node)) {
return this.options.keepConverter
ruleForNode: function (node) {
if (this.filterValue(this.options.keepRule, node)) {
return this.options.keepRule
}
if (this.filterValue(this.options.removeConverter, node)) {
return this.options.removeConverter
if (this.filterValue(this.options.removeRule, node)) {
return this.options.removeRule
}

@@ -922,3 +928,3 @@

filterValue: function filterValue (rule, node) {
filterValue: function (rule, node) {
var filter = rule.filter;

@@ -936,3 +942,3 @@ if (typeof filter === 'string') {

postProcess: function postProcess (output) {
postProcess: function (output) {
for (var key in this.options.rules) {

@@ -939,0 +945,0 @@ var rule = this.options.rules[key];

{
"name": "turndown",
"description": "A library that converts HTML to Markdown",
"version": "0.0.6",
"version": "0.0.8",
"author": "Dom Christie",

@@ -6,0 +6,0 @@ "browser": {

@@ -49,4 +49,8 @@ # Turndown

## Methods
## License
turndown is copyright © 2017+ Dom Christie and released under the MIT license.
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