From 6f52851a8510950ff0620b325dd361a9c72fe841 Mon Sep 17 00:00:00 2001 From: fredck Date: Mon, 17 Aug 2020 16:11:56 +0200 Subject: [PATCH 1/3] Upgraded to Marked v1.1.1. --- packages/ckeditor5-markdown-gfm/package.json | 2 +- .../src/markdown2html/markdown2html.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/ckeditor5-markdown-gfm/package.json b/packages/ckeditor5-markdown-gfm/package.json index dac783c2faf..484117b82ed 100644 --- a/packages/ckeditor5-markdown-gfm/package.json +++ b/packages/ckeditor5-markdown-gfm/package.json @@ -12,7 +12,7 @@ "dependencies": { "@ckeditor/ckeditor5-core": "^21.0.0", "@ckeditor/ckeditor5-engine": "^21.0.0", - "marked": "^0.7.0", + "marked": "^1.1.1", "turndown": "^6.0.0", "turndown-plugin-gfm": "^1.0.2" }, diff --git a/packages/ckeditor5-markdown-gfm/src/markdown2html/markdown2html.js b/packages/ckeditor5-markdown-gfm/src/markdown2html/markdown2html.js index 3c481227ed5..d17a75a3d00 100644 --- a/packages/ckeditor5-markdown-gfm/src/markdown2html/markdown2html.js +++ b/packages/ckeditor5-markdown-gfm/src/markdown2html/markdown2html.js @@ -9,6 +9,15 @@ import marked from 'marked'; +// Overrides. +marked.use( { + tokenizer: { + // Disable the autolink rule in the lexer. + autolink: () => null, + url: () => null + } +} ); + /** * Parses markdown string to an HTML. * @@ -26,7 +35,3 @@ export default function markdown2html( markdown ) { } export { marked }; - -// Disable the autolink rule in the lexer (point it to a regex that always fail). -marked.InlineLexer.rules.breaks.autolink = /^\b$/; -marked.InlineLexer.rules.breaks.url = /^\b$/; From a7dca16514209e8869763f1f51e065401c546eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Go=C5=82aszewski?= Date: Tue, 18 Aug 2020 15:49:11 +0200 Subject: [PATCH 2/3] Update code tests for markdown gfm plugin. --- .../ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js index 9af7bc977d5..df6da3d8e19 100644 --- a/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js +++ b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js @@ -27,11 +27,11 @@ describe( 'GFMDataProcessor', () => { testDataProcessor( 'regular text and` inline code`', - '

regular text andinline code

', + '

regular text and inline code

', // When converting back it will be normalized and spaces // at the beginning of inline code will be removed. - 'regular text and`inline code`' + 'regular text and `inline code`' ); } ); From 5401c73d099efae08ba730e62040b1b1b4ba14a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Go=C5=82aszewski?= Date: Tue, 18 Aug 2020 15:54:53 +0200 Subject: [PATCH 3/3] Update blockquote > pre tests in markdown gfm plugin. --- .../tests/gfmdataprocessor/blockquotes.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/blockquotes.js b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/blockquotes.js index 65369f2a93a..1a61257e1fe 100644 --- a/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/blockquotes.js +++ b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/blockquotes.js @@ -115,8 +115,23 @@ describe( 'GFMDataProcessor', () => { '' + 'code 2' + '' + - '' + - '' + // Space after `` might be due to bug in engine. See: https://github.com/ckeditor/ckeditor5/issues/7863. + ' ' + + '', + + '> Example 1:\n' + + '>\n' + + '> ```\n' + + '> code 1\n' + + '> ```\n' + + '>\n' + + '> Example 2:\n' + + '>\n' + + '> ```\n' + + '> code 2\n' + + '> ```' + + // The below is an artefact of space after ``. See comment above & https://github.com/ckeditor/ckeditor5/issues/7863. + '\n>\n>' ); } ); @@ -154,7 +169,8 @@ describe( 'GFMDataProcessor', () => { '' + 'code 2' + '' + - '' + + // Space after `` might be due to bug in engine. See: https://github.com/ckeditor/ckeditor5/issues/7863. + ' ' + '', // When converting back to data, DataProcessor will normalize tabs to ```. @@ -168,7 +184,9 @@ describe( 'GFMDataProcessor', () => { '>\n' + '> ```\n' + '> code 2\n' + - '> ```' + '> ```' + + // The below is an artefact of space after ``. See comment above & https://github.com/ckeditor/ckeditor5/issues/7863. + '\n>\n>' ); } ); } );