Comparing version 1.2.2 to 1.3.0
@@ -14,18 +14,27 @@ 'use strict'; | ||
function escapeMarkdownPart(input) { | ||
return [ | ||
var i = 0; | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
return input.split(/(`.*?`)/g).map(function (part) { | ||
// do not escape the code | ||
if (0 !== i++ % 2) { | ||
return part; | ||
} | ||
// escaping less and more signs | ||
[/\</g, '<'], [/\>/g, '>'], | ||
return [ | ||
// convert line break into markdown hardbrake | ||
[/\n/g, ' \n']].reduce(function (input, _ref) { | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
var replaceFrom = _ref2[0]; | ||
var replaceTo = _ref2[1]; | ||
return input.replace(replaceFrom, replaceTo); | ||
}, input); | ||
// escaping less and more signs | ||
[/\</g, '<'], [/\>/g, '>'], | ||
// convert line break into markdown hardbrake | ||
[/\n/g, ' \n']].reduce(function (input, _ref) { | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
var replaceFrom = _ref2[0]; | ||
var replaceTo = _ref2[1]; | ||
return input.replace(replaceFrom, replaceTo); | ||
}, part); | ||
}).join(''); | ||
} | ||
@@ -32,0 +41,0 @@ |
27
index.js
function escapeMarkdownPart(input) { | ||
return [ | ||
let i = 0; | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
return input.split(/(`.*?`)/g).map(part => { | ||
// do not escape the code | ||
if (0 !== i++ % 2) { | ||
return part; | ||
} | ||
// escaping less and more signs | ||
[/\</g, '<'], | ||
[/\>/g, '>'], | ||
return [ | ||
// convert line break into markdown hardbrake | ||
[/\n/g, ' \n'] | ||
// escaping symbols: # * ( ) [ ] _ ` | ||
[/([\#\*\(\)\[\]\_\`\\])/g, '\\$1'], | ||
].reduce((input, [replaceFrom, replaceTo]) => input.replace(replaceFrom, replaceTo), input); | ||
// escaping less and more signs | ||
[/\</g, '<'], | ||
[/\>/g, '>'], | ||
// convert line break into markdown hardbrake | ||
[/\n/g, ' \n'] | ||
].reduce((input, [replaceFrom, replaceTo]) => input.replace(replaceFrom, replaceTo), part); | ||
}).join(''); | ||
} | ||
@@ -16,0 +25,0 @@ |
{ | ||
"name": "tweet.md", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Render tweet to markdown", | ||
@@ -5,0 +5,0 @@ "main": "index.es5.js", |
@@ -59,1 +59,9 @@ # Tweet markdown renderer | ||
### [04-code.json](examples/04-code.json) | ||
Tweet [572444133740179457](https://twitter.com/jsunderhood/status/572444133740179457) by Разработчик | ||
- - - | ||
`capitalize(trim(string))` — композиция двух операций. | ||
- - - | ||
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
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
10363
187
67