markdown-draft-js
Advanced tools
Comparing version 0.7.0 to 1.0.0
@@ -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 @@ }); |
@@ -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); | ||
}); | ||
}); |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
85707
1746
1