浏览代码

Added more texts for code, headers and links. Fixed path to ckeditor5-dev-lint in gulpfile.

Szymon Kupś 9 年之前
父节点
当前提交
e387016a34

+ 1 - 1
packages/ckeditor5-markdown-gfm/gulpfile.js

@@ -19,7 +19,7 @@ const config = {
 	]
 };
 
-const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
+const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' )( config );
 
 gulp.task( 'lint', ckeditor5Lint.lint );
 gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );

+ 105 - 0
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js

@@ -63,6 +63,111 @@ describe( 'GFMDataProcessor', () => {
 
 				expect( stringify( viewFragment ) ).to.equal( '<pre><code>the lines in this block  \nall contain trailing spaces  </code></pre>' );
 			} );
+
+			it( 'should process code block with language name', () => {
+				const viewFragment = dataProcessor.toView(
+					'``` js\n' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');\n' +
+					'```'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+						'<code class="lang-js">' +
+							'var a = \'hello\';\n' +
+							'console.log(a + \' world\');' +
+						'</code>' +
+					'</pre>' );
+			} );
+
+			it( 'should process code block with language name and using ~~~ as delimiter', () => {
+				const viewFragment = dataProcessor.toView(
+					'~~~ bash\n' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');\n' +
+					'~~~'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+					'<code class="lang-bash">' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');' +
+					'</code>' +
+					'</pre>' );
+			} );
+
+			it( 'should process code block with language name and using ``````` as delimiter', () => {
+				const viewFragment = dataProcessor.toView(
+					'``````` js\n' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');\n' +
+					'```````'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+					'<code class="lang-js">' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');' +
+					'</code>' +
+					'</pre>' );
+			} );
+
+			it( 'should process code block with language name and using ~~~~~~~~~~ as delimiter', () => {
+				const viewFragment = dataProcessor.toView(
+					'~~~~~~~~~~ js\n' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');\n' +
+					'~~~~~~~~~~'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+					'<code class="lang-js">' +
+					'var a = \'hello\';\n' +
+					'console.log(a + \' world\');' +
+					'</code>' +
+					'</pre>' );
+			} );
+
+			it( 'should process empty code block', () => {
+				const viewFragment = dataProcessor.toView(
+					'``` js\n' +
+					'```'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+						'<code class="lang-js">' +
+						'</code>' +
+					'</pre>' );
+			} );
+
+			it( 'should process code block with empty line', () => {
+				const viewFragment = dataProcessor.toView(
+					'``` js\n\n' +
+					'```'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<pre>' +
+					'<code class="lang-js">' +
+					'</code>' +
+					'</pre>'
+				);
+			} );
+
+			it( 'should process nested code', () => {
+				const viewFragment = dataProcessor.toView(
+					'````` code `` code ``` `````'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal(
+					'<p><code>code `` code ``` </code></p>'
+				);
+			} );
 		} );
 	} );
 } );

+ 6 - 0
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/headers.js

@@ -62,6 +62,12 @@ describe( 'GFMDataProcessor', () => {
 
 				expect( stringify( viewFragment ) ).to.equal( '<h6 id="level-6">Level 6</h6>' );
 			} );
+
+			it( 'should create header when more spaces before text', () => {
+				const viewFragment = dataProcessor.toView( '#      Level 1' );
+
+				expect( stringify( viewFragment ) ).to.equal( '<h1 id="level-1">Level 1</h1>' );
+			} );
 		} );
 	} );
 } );

+ 9 - 0
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/links.js

@@ -331,6 +331,15 @@ describe( 'GFMDataProcessor', () => {
 
 				expect( stringify( viewFragment ) ).to.equal( '<p>This is <a href="foo">multiline<br></br>reference</a></p>' );
 			} );
+
+			it( 'should process reference links case-insensitve', () => {
+				const viewFragment = dataProcessor.toView(
+					'[hi]\n' +
+					'[HI]: /url'
+				);
+
+				expect( stringify( viewFragment ) ).to.equal( '<p><a href="/url">hi</a></p>' );
+			} );
 		} );
 	} );
 } );