| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- /**
- * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- import { testDataProcessor } from '../_utils/utils';
- describe( 'GFMDataProcessor', () => {
- describe( 'tables', () => {
- it( 'should process tables', () => {
- testDataProcessor(
- '| Heading 1 | Heading 2\n' +
- '| --- | ---\n' +
- '| Cell 1 | Cell 2\n' +
- '| Cell 3 | Cell 4\n',
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<th>Heading 1</th>' +
- '<th>Heading 2</th>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td>Cell 1</td>' +
- '<td>Cell 2</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Cell 3</td>' +
- '<td>Cell 4</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>',
- // After converting back it will be normalized.
- '| Heading 1 | Heading 2 |\n' +
- '| --- | --- |\n' +
- '| Cell 1 | Cell 2 |\n' +
- '| Cell 3 | Cell 4 |'
- );
- } );
- it( 'should process tables with aligned columns', () => {
- testDataProcessor(
- '| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
- '| :------: | -------: | :------- | -------- |\n' +
- '| Cell 1 | Cell 2 | Cell 3 | Cell 4 |\n' +
- '| Cell 5 | Cell 6 | Cell 7 | Cell 8 |',
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<th align="center">Header 1</th>' +
- '<th align="right">Header 2</th>' +
- '<th align="left">Header 3</th>' +
- '<th>Header 4</th>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td align="center">Cell 1</td>' +
- '<td align="right">Cell 2</td>' +
- '<td align="left">Cell 3</td>' +
- '<td>Cell 4</td>' +
- '</tr>' +
- '<tr>' +
- '<td align="center">Cell 5</td>' +
- '<td align="right">Cell 6</td>' +
- '<td align="left">Cell 7</td>' +
- '<td>Cell 8</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>',
- // After converting back it will be normalized.
- '| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
- '| :-: | --: | :-- | --- |\n' +
- '| Cell 1 | Cell 2 | Cell 3 | Cell 4 |\n' +
- '| Cell 5 | Cell 6 | Cell 7 | Cell 8 |'
- );
- } );
- it( 'should process not table without borders', () => {
- testDataProcessor(
- 'Header 1 | Header 2\n' +
- '-------- | --------\n' +
- 'Cell 1 | Cell 2\n' +
- 'Cell 3 | Cell 4',
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<th>Header 1</th>' +
- '<th>Header 2</th>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td>Cell 1</td>' +
- '<td>Cell 2</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Cell 3</td>' +
- '<td>Cell 4</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>',
- // After converting back it will be normalized.
- '| Header 1 | Header 2 |\n' +
- '| --- | --- |\n' +
- '| Cell 1 | Cell 2 |\n' +
- '| Cell 3 | Cell 4 |'
- );
- } );
- it( 'should process formatting inside cells', () => {
- testDataProcessor(
- 'Header 1|Header 2|Header 3|Header 4\n' +
- ':-------|:------:|-------:|--------\n' +
- '*Cell 1* |**Cell 2** |~Cell 3~ |Cell 4',
- '<table>' +
- '<thead>' +
- '<tr>' +
- '<th align="left">Header 1</th>' +
- '<th align="center">Header 2</th>' +
- '<th align="right">Header 3</th>' +
- '<th>Header 4</th>' +
- '</tr>' +
- '</thead>' +
- '<tbody>' +
- '<tr>' +
- '<td align="left">' +
- '<em>Cell 1</em>' +
- '</td>' +
- '<td align="center">' +
- '<strong>Cell 2</strong>' +
- '</td>' +
- '<td align="right">' +
- '<del>Cell 3</del>' +
- '</td>' +
- '<td>' +
- 'Cell 4' +
- '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>',
- // After converting back it will be normalized.
- '| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
- '| :-- | :-: | --: | --- |\n' +
- '| _Cell 1_ | **Cell 2** | ~Cell 3~ | Cell 4 |'
- );
- } );
- } );
- } );
|