/** * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import { testDataProcessor as test } from '/tests/markdown-gfm/_utils/utils.js'; describe( 'GFMDataProcessor', () => { describe( 'code', () => { it( 'should process inline code', () => { test( 'regular text and `inline code`', // GitHub is rendering as: //
regular text and inline code
regular text and inline code
this is code and this is too
this is code and this is too
regular text andinline code
regular text andinline code
`backticks`
`backticks`
some `backticks` inside
some `backticks` inside
code block
//
'code block',
// When converting back tabs are normalized to ```.
'```\n' +
'code block\n' +
'```'
);
} );
it( 'should process code blocks indented with spaces', () => {
test(
' code block',
// GitHub is rendering as:
// code block
//
'code block',
// When converting back tabs are normalized to ```.
'```\n' +
'code block\n' +
'```'
);
} );
it( 'should process multi line code blocks indented with tabs', () => {
test(
' first line\n' +
' second line',
// GitHub is rendering as:
// first line
// second line
//
'first line\n' +
'second line',
// When converting back tabs are normalized to ```.
'```\n' +
'first line\n' +
'second line\n' +
'```'
);
} );
it( 'should process multi line code blocks indented with spaces', () => {
test(
' first line\n' +
' second line',
// GitHub is rendering as:
// first line
// second line
//
'first line\n' +
'second line',
// When converting back spaces are normalized to ```.
'```\n' +
'first line\n' +
'second line\n' +
'```'
);
} );
it( 'should process multi line code blocks with trailing spaces', () => {
test(
' the lines in this block \n' +
' all contain trailing spaces ',
// GitHub is rendering as:
// the lines in this block
// all contain trailing spaces
//
'the lines in this block \n' +
'all contain trailing spaces ',
// When converting back tabs are normalized to ```.
'```\n' +
'the lines in this block \n' +
'all contain trailing spaces \n' +
'```'
);
} );
it( 'should process code block with language name', () => {
test(
'``` js\n' +
'var a = \'hello\';\n' +
'console.log(a + \' world\');\n' +
'```',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'var a = \'hello\';\n' +
'console.log(a + \' world\');'
);
} );
it( 'should process code block with language name and using ~~~ as delimiter', () => {
test(
'~~~ bash\n' +
'#!/bin/bash\n' +
'~~~',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'#!/bin/bash',
// When converting back ~~~ are normalized to ```.
'``` bash\n' +
'#!/bin/bash\n' +
'```'
);
} );
it( 'should process code block with language name and using ``````` as delimiter', () => {
test(
'``````` js\n' +
'var a = \'hello\';\n' +
'console.log(a + \' world\');\n' +
'```````',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'var a = \'hello\';\n' +
'console.log(a + \' world\');',
// When converting back ``````` are normalized to ```.
'``` js\n' +
'var a = \'hello\';\n' +
'console.log(a + \' world\');\n' +
'```'
);
} );
it( 'should process code block with language name and using ~~~~~~~~~~ as delimiter', () => {
test(
'~~~~~~~~~~ js\n' +
'var a = \'hello\';\n' +
'console.log(a + \' world\');\n' +
'~~~~~~~~~~',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'var a = \'hello\';\n' +
'console.log(a + \' world\');',
// When converting back ~~~~~~~~~~ are normalized to ```.
'``` js\n' +
'var a = \'hello\';\n' +
'console.log(a + \' world\');\n' +
'```'
);
} );
it( 'should process empty code block', () => {
test(
'``` js\n' +
'```',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'',
// When converting back, empty code blocks will be removed.
// This might be an issue when switching from source to editor
// but changing this cannot be done in to-markdown converters.
''
);
} );
it( 'should process code block with empty line', () => {
test(
'``` js\n' +
'\n' +
'```',
// GitHub is rendering as special html with syntax highlighting.
// We will need to handle this separately by some feature.
'',
// When converting back, empty code blocks will be removed.
// This might be an issue when switching from source to editor
// but changing this cannot be done in to-markdown converters.
''
);
} );
it( 'should process nested code', () => {
test(
'````` code `` code ``` `````',
// GitHub is rendering as:
// code `` code ```
code `` code ```