New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atomist/slack-messages

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atomist/slack-messages - npm Package Compare versions

Comparing version 1.0.2-master.20181115151310 to 1.1.0-master.20181115202354

4

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

### Fixed
- Code within link names breaks Slack rendering. [#37](https://github.com/atomist/slack-messages/issues/37)
## [1.0.1](https://github.com/atomist/slack-messages/compare/1.0.0...1.0.1) - 2018-11-09

@@ -12,0 +16,0 @@

@@ -122,3 +122,31 @@ "use strict";

}
/** Provide a unique identifier for later replacement. */
function codeTag(i) {
return `%.%CODE_PROCESSOR_CODE${i}%.%`;
}
/**
* Transform everything but the interior of inline code segments,
* i.e., \`code\`, but still be able to process elements that wrap
* around inlide code formatting.
*
* @param text input string
* @param transform function that takes the whole string with inline
* code segments "hidden" and performs transformation
* @return transformed string with unchanged inline code segments
*/
function codeProcessor(text) {
const hunks = text.split(/(`.*?`)/);
const codes = new Array(hunks.length);
for (let i = 1; i < hunks.length; i += 2) {
codes[i] = hunks[i];
hunks[i] = codeTag(i);
}
const transformed = convertMarkdown(hunks.join(""));
let restored = transformed;
for (let i = 1; i < hunks.length; i += 2) {
restored = restored.replace(codeTag(i), codes[i]);
}
return restored;
}
/**
* Convert GitHub-flavored Markdown to Slack message markup. This is

@@ -132,5 +160,6 @@ * not a complete implementation of a Markdown parser, but it does its

function githubToSlack(text) {
return splitProcessor_1.splitProcessor(text, convertMarkdown);
const codeBlock = /(```[\S\s]*?```(?!`))/g;
return splitProcessor_1.splitProcessor(text, codeProcessor, codeBlock);
}
exports.githubToSlack = githubToSlack;
//# sourceMappingURL=Markdown.js.map

2

lib/SlackMessages.d.ts

@@ -17,3 +17,3 @@ /**

/**
* Escapes special Slack characters.
* Encode special Slack characters and HTML entities.
*/

@@ -20,0 +20,0 @@ export declare function escape(text: string): string;

@@ -34,7 +34,9 @@ "use strict";

/**
* Escapes special Slack characters.
* Encode special Slack characters and HTML entities.
*/
function escape(text) {
if (text) {
return splitProcessor_1.splitProcessor(text, i => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
const entify = (i) => i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
const htmlEntities = /(&(?:\w+|#\d+);)/;
return splitProcessor_1.splitProcessor(text, entify, htmlEntities);
}

@@ -41,0 +43,0 @@ else {

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

export declare const codeBlockSplitter: RegExp;
/**

@@ -12,2 +11,2 @@ * Perform transformations on input string, skipping sections that match

*/
export declare function splitProcessor(text: string, transform: (i: string) => string, splitter?: RegExp): string;
export declare function splitProcessor(text: string, transform: (i: string) => string, splitter: RegExp): string;

@@ -18,3 +18,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.codeBlockSplitter = /(```[\S\s]*?```(?!`)|`.*?`)/mg;
/**

@@ -30,3 +29,3 @@ * Perform transformations on input string, skipping sections that match

*/
function splitProcessor(text, transform, splitter = exports.codeBlockSplitter) {
function splitProcessor(text, transform, splitter) {
const hunks = text.split(splitter);

@@ -33,0 +32,0 @@ for (let i = 0; i < hunks.length; i += 2) {

{
"name": "@atomist/slack-messages",
"version": "1.0.2-master.20181115151310",
"version": "1.1.0-master.20181115202354",
"description": "Atomist utilities for creating formatted Slack messages",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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