Comparing version 1.0.2 to 1.1.0
@@ -13,7 +13,7 @@ 'use strict'; | ||
function escapeMarkdown(input) { | ||
function escapeMarkdownPart(input) { | ||
return [ | ||
// escaping symbols: # * ( ) [ ] _ | ||
[/([#\*\(\)\[\]\_\/`])/g, '\\$1'], | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
@@ -30,16 +30,22 @@ // escaping less and more signs | ||
function escapeMarkdown(input) { | ||
return escapeMarkdownPart(input) | ||
// escaping period after number at the string start | ||
.replace(/^(\d+)\./, '$1\\.'); | ||
} | ||
function renderEntityMention(data) { | ||
return '[@' + escapeMarkdown(data.screen_name) + '](https://twitter.com/' + data.screen_name + ' "' + data.name + '")'; | ||
return '[@' + escapeMarkdownPart(data.screen_name) + '](https://twitter.com/' + data.screen_name + ' "' + data.name + '")'; | ||
} | ||
function renderEntityMedia(data) { | ||
return '[' + escapeMarkdown(data.display_url) + '](' + data.url + ')'; | ||
return '[' + escapeMarkdownPart(data.display_url) + '](' + data.url + ')'; | ||
} | ||
function renderEntityHashtag(data) { | ||
return '[#' + escapeMarkdown(data.text) + '](https://twitter.com/search?q=%23' + data.text + ')'; | ||
return '[#' + escapeMarkdownPart(data.text) + '](https://twitter.com/search?q=%23' + data.text + ')'; | ||
} | ||
function renderEntityUrl(data) { | ||
return '[' + escapeMarkdown(data.display_url) + '](' + data.url + ' "' + data.expanded_url + '")'; | ||
return '[' + escapeMarkdownPart(data.display_url) + '](' + data.url + ' "' + data.expanded_url + '")'; | ||
} | ||
@@ -86,3 +92,3 @@ | ||
if (replacement[2] < lastPos) { | ||
output.push(escapeMarkdown(text.substr(replacement[2], lastPos - replacement[2]))); | ||
output.push(escapeMarkdownPart(text.substr(replacement[2], lastPos - replacement[2]))); | ||
} | ||
@@ -89,0 +95,0 @@ |
22
index.js
@@ -1,6 +0,6 @@ | ||
function escapeMarkdown(input) { | ||
function escapeMarkdownPart(input) { | ||
return [ | ||
// escaping symbols: # * ( ) [ ] _ | ||
[/([#\*\(\)\[\]\_\/`])/g, '\\$1'], | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
@@ -14,16 +14,22 @@ // escaping less and more signs | ||
function escapeMarkdown(input) { | ||
return escapeMarkdownPart(input) | ||
// escaping period after number at the string start | ||
.replace(/^(\d+)\./, '$1\\.'); | ||
} | ||
function renderEntityMention(data) { | ||
return `[@${escapeMarkdown(data.screen_name)}](https://twitter.com/${data.screen_name} "${data.name}")`; | ||
return `[@${escapeMarkdownPart(data.screen_name)}](https://twitter.com/${data.screen_name} "${data.name}")`; | ||
} | ||
function renderEntityMedia(data) { | ||
return `[${escapeMarkdown(data.display_url)}](${data.url})`; | ||
return `[${escapeMarkdownPart(data.display_url)}](${data.url})`; | ||
} | ||
function renderEntityHashtag(data) { | ||
return `[#${escapeMarkdown(data.text)}](https://twitter.com/search?q=%23${data.text})`; | ||
return `[#${escapeMarkdownPart(data.text)}](https://twitter.com/search?q=%23${data.text})`; | ||
} | ||
function renderEntityUrl(data) { | ||
return `[${escapeMarkdown(data.display_url)}](${data.url} "${data.expanded_url}")`; | ||
return `[${escapeMarkdownPart(data.display_url)}](${data.url} "${data.expanded_url}")`; | ||
} | ||
@@ -70,3 +76,3 @@ | ||
output.push( | ||
escapeMarkdown( | ||
escapeMarkdownPart( | ||
text.substr( | ||
@@ -73,0 +79,0 @@ replacement[2], |
{ | ||
"name": "tweet.md", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Render tweet to markdown", | ||
@@ -8,4 +8,6 @@ "main": "index.es5.js", | ||
"transpile": "babel index.js --out-file index.es5.js", | ||
"examples": "babel-node examples.js", | ||
"test": "mocha -r babel/register", | ||
"prepublish": "npm run test && npm run transpile" | ||
"preversion": "npm run examples", | ||
"prepublish": "npm run test && npm run transpile && npm run examples" | ||
}, | ||
@@ -12,0 +14,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
22555
10
606
1
58