headers.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import { testDataProcessor as test } from 'ckeditor5-markdown-gfm/tests/_utils/utils';
  6. describe( 'GFMDataProcessor', () => {
  7. describe( 'headers', () => {
  8. it( 'should process level 1 header #1', () => {
  9. test(
  10. '# Level 1',
  11. '<h1>Level 1</h1>'
  12. );
  13. } );
  14. it( 'should process level 1 header #2', () => {
  15. test(
  16. 'Level 1\n' +
  17. '===',
  18. '<h1>Level 1</h1>',
  19. // When converting back it will be normalized to # representation.
  20. '# Level 1'
  21. );
  22. } );
  23. it( 'should process level 2 header #1', () => {
  24. test(
  25. '## Level 2',
  26. '<h2>Level 2</h2>'
  27. );
  28. } );
  29. it( 'should process level 2 header #2', () => {
  30. test(
  31. 'Level 2\n' +
  32. '---',
  33. '<h2>Level 2</h2>',
  34. // When converting back it will be normalized to ## representation.
  35. '## Level 2'
  36. );
  37. } );
  38. it( 'should process level 3 header', () => {
  39. test(
  40. '### Level 3',
  41. '<h3>Level 3</h3>'
  42. );
  43. } );
  44. it( 'should process level 4 header', () => {
  45. test(
  46. '#### Level 4',
  47. '<h4>Level 4</h4>'
  48. );
  49. } );
  50. it( 'should process level 5 header', () => {
  51. test(
  52. '##### Level 5',
  53. '<h5>Level 5</h5>'
  54. );
  55. } );
  56. it( 'should process level 6 header', () => {
  57. test(
  58. '###### Level 6',
  59. '<h6>Level 6</h6>'
  60. );
  61. } );
  62. it( 'should create header when more spaces before text', () => {
  63. test(
  64. '# Level 1',
  65. '<h1>Level 1</h1>',
  66. // When converting back it will be normalized to # Level 1.
  67. '# Level 1'
  68. );
  69. } );
  70. it( 'should process headers placed next to each other #1', () => {
  71. test(
  72. '# header\n' +
  73. '# header',
  74. '<h1>header</h1><h1>header</h1>'
  75. );
  76. } );
  77. it( 'should process headers placed next to each other #2', () => {
  78. test(
  79. '# header\n' +
  80. '## header\n' +
  81. '### header',
  82. '<h1>header</h1><h2>header</h2><h3>header</h3>'
  83. );
  84. } );
  85. it( 'should process headers followed by a paragraph', () => {
  86. test(
  87. '# header\n\n' +
  88. 'paragraph',
  89. '<h1>header</h1><p>paragraph</p>'
  90. );
  91. } );
  92. } );
  93. } );