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

slackify-markdown

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slackify-markdown - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "slackify-markdown",
"version": "1.0.2",
"version": "1.0.3",
"description": "Convert markdown into Slack-specific markdown",

@@ -5,0 +5,0 @@ "license": "MIT",

const { Compiler } = require('remark-stringify');
const { isURL } = require('./utils');
const { isURL, wrap } = require('./utils');
// fixes slack in-word formatting (e.g. hel*l*o)
const zeroWidthSpace = String.fromCharCode(0x200B);
const visitors = {
heading(node) {
// make headers to be just *strong*
return `*${this.content(node)}*`;
return wrap(this.content(node), '*');
},
strong(node) {
return `*${this.content(node)}*`;
return wrap(this.content(node), zeroWidthSpace, '*');
},
delete(node) {
return `~${this.content(node)}~`;
return wrap(this.content(node), zeroWidthSpace, '~');
},
emphasis(node) {
return `_${this.content(node)}_`;
return wrap(this.content(node), zeroWidthSpace, '_');
},

@@ -33,7 +36,11 @@

code(node) {
// delete language prefix for deprecated markdown formatters (old Bitbucket Editor)
const content = node.value.replace(/^#![a-z]+\n/, ''); // ```\n#!javascript\ncode block\n```
return wrap(content, '```', '\n');
},
link(node) {
const text = node.title || this.content(node);
const url = this.encode(node.url || '', node);
if (!isURL(url)) return url;
return `<${url}|${text}>`;
return this.visitors.url.call(this, node, text);
},

@@ -43,2 +50,6 @@

const text = node.title || node.alt;
return this.visitors.url.call(this, node, text);
},
url(node, text) {
const url = this.encode(node.url || '', node);

@@ -48,7 +59,2 @@ if (!isURL(url)) return url;

},
code(node) {
const fence = '```';
return `${fence}\n${node.value}\n${fence}`;
},
};

@@ -55,0 +61,0 @@

@@ -11,2 +11,10 @@ const { URL } = require('url');

},
wrap(string, ...wrappers) {
return [
...wrappers,
string,
...wrappers.reverse(),
].join('');
},
};
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