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

markdown-draft-js

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-draft-js - npm Package Compare versions

Comparing version 0.7.0 to 1.0.0

8

lib/draft-to-markdown.js

@@ -5,2 +5,9 @@ 'use strict';

// This escapes some markdown but there's a few cases that are TODO -
// - List items
// - Back tics (see https://github.com/Rosey/markdown-draft-js/issues/52#issuecomment-388458017)
// - Complex markdown, like links or images. Not sure it's even worth it, because if you're typing
// that into draft chances are you know its markdown and maybe expect it convert? :/
var MARKDOWN_STYLE_CHARACTERS = /(\*|_|~|>|#|\\)/;
// A map of draftjs block types -> markdown open and close characters

@@ -305,2 +312,3 @@ // Both the open and close methods must exist, even if they simply return an empty string.

character = character.replace(MARKDOWN_STYLE_CHARACTERS, '\\$1');
markdownString += character;

@@ -307,0 +315,0 @@ });

2

package.json

@@ -5,3 +5,3 @@ {

"author": "Rose Robertson",
"version": "0.7.0",
"version": "1.0.0",
"license": "MIT",

@@ -8,0 +8,0 @@ "repository": {

const TRAILING_WHITESPACE = /[ |\u0020|\t]*$/;
// This escapes some markdown but there's a few cases that are TODO -
// - List items
// - Back tics (see https://github.com/Rosey/markdown-draft-js/issues/52#issuecomment-388458017)
// - Complex markdown, like links or images. Not sure it's even worth it, because if you're typing
// that into draft chances are you know its markdown and maybe expect it convert? :/
const MARKDOWN_STYLE_CHARACTERS = /(\*|_|~|>|#|\\)/;
// A map of draftjs block types -> markdown open and close characters

@@ -306,2 +313,3 @@ // Both the open and close methods must exist, even if they simply return an empty string.

character = character.replace(MARKDOWN_STYLE_CHARACTERS, '\\$1');
markdownString += character;

@@ -308,0 +316,0 @@ });

@@ -230,2 +230,11 @@ import { markdownToDraft, draftToMarkdown } from '../src/index';

});
it ('escapes markdown characters', function () {
/* eslint-disable */
var rawObject = {"entityMap":{},"blocks":[{"key":"dvfr1","text":"Test _not italic_ Test **not bold**","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}]};
/* eslint-enable */
var markdown = draftToMarkdown(rawObject);
expect(markdown).toEqual('Test \\_not italic\\_ Test \\*\\*not bold\\*\\*');
});
});

@@ -96,2 +96,18 @@ import { markdownToDraft, draftToMarkdown } from '../src/index';

});
it ('renders escaped italics correctly', function () {
var markdown = 'test \\_not italic\\_ test';
var rawDraftConversion = markdownToDraft(markdown);
var markdownConversion = draftToMarkdown(rawDraftConversion);
expect(markdownConversion).toEqual(markdown);
});
it ('renders escaped bold correctly', function () {
var markdown = 'test \\*\\*not italic\\*\\* test';
var rawDraftConversion = markdownToDraft(markdown);
var markdownConversion = draftToMarkdown(rawDraftConversion);
expect(markdownConversion).toEqual(markdown);
});
});
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