horizontal-rules.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import { testDataProcessor } from '../_utils/utils';
  6. describe( 'GFMDataProcessor', () => {
  7. // Horizontal rules are always rendered by GitHub as <hr> and normalized when converting
  8. // back to ---.
  9. describe( 'horizontal rules', () => {
  10. describe( 'dashes', () => {
  11. it( '#1', () => {
  12. testDataProcessor( '---', '<hr></hr>', '---' );
  13. } );
  14. it( '#2', () => {
  15. testDataProcessor( ' ---', '<hr></hr>', '---' );
  16. } );
  17. it( '#3', () => {
  18. testDataProcessor( ' ---', '<hr></hr>', '---' );
  19. } );
  20. it( '#4', () => {
  21. testDataProcessor( ' ---', '<hr></hr>', '---' );
  22. } );
  23. it( '#5 - code', () => {
  24. testDataProcessor(
  25. ' ---',
  26. // Four spaces are interpreted as code block.
  27. '<pre><code>---</code></pre>',
  28. // Code block will be normalized to ``` representation.
  29. '```\n' +
  30. '---\n' +
  31. '```'
  32. );
  33. } );
  34. } );
  35. describe( 'dashes with spaces', () => {
  36. it( '#1', () => {
  37. testDataProcessor( '- - -', '<hr></hr>', '---' );
  38. } );
  39. it( '#2', () => {
  40. testDataProcessor( ' - - -', '<hr></hr>', '---' );
  41. } );
  42. it( '#3', () => {
  43. testDataProcessor( ' - - -', '<hr></hr>', '---' );
  44. } );
  45. it( '#4', () => {
  46. testDataProcessor( ' - - -', '<hr></hr>', '---' );
  47. } );
  48. it( '#5 - code', () => {
  49. testDataProcessor(
  50. ' - - -',
  51. // Four spaces are interpreted as code block.
  52. '<pre><code>- - -</code></pre>',
  53. // Code block will be normalized to ``` representation.
  54. '```\n' +
  55. '- - -\n' +
  56. '```'
  57. );
  58. } );
  59. } );
  60. describe( 'asterisks', () => {
  61. it( '#1', () => {
  62. testDataProcessor( '***', '<hr></hr>', '---' );
  63. } );
  64. it( '#2', () => {
  65. testDataProcessor( ' ***', '<hr></hr>', '---' );
  66. } );
  67. it( '#3', () => {
  68. testDataProcessor( ' ***', '<hr></hr>', '---' );
  69. } );
  70. it( '#4', () => {
  71. testDataProcessor( ' ***', '<hr></hr>', '---' );
  72. } );
  73. it( '#5 - code', () => {
  74. testDataProcessor(
  75. ' ***',
  76. // Four spaces are interpreted as code block.
  77. '<pre><code>***</code></pre>',
  78. // Code block will be normalized to ``` representation.
  79. '```\n' +
  80. '***\n' +
  81. '```'
  82. );
  83. } );
  84. } );
  85. describe( 'asterisks with spaces', () => {
  86. it( '#1', () => {
  87. testDataProcessor( '* * *', '<hr></hr>', '---' );
  88. } );
  89. it( '#2', () => {
  90. testDataProcessor( ' * * *', '<hr></hr>', '---' );
  91. } );
  92. it( '#3', () => {
  93. testDataProcessor( ' * * *', '<hr></hr>', '---' );
  94. } );
  95. it( '#4', () => {
  96. testDataProcessor( ' * * *', '<hr></hr>', '---' );
  97. } );
  98. it( '#5 - code', () => {
  99. testDataProcessor(
  100. ' * * *',
  101. // Four spaces are interpreted as code block.
  102. '<pre><code>* * *</code></pre>',
  103. // Code block will be normalized to ``` representation.
  104. '```\n' +
  105. '* * *\n' +
  106. '```'
  107. );
  108. } );
  109. } );
  110. describe( 'underscores', () => {
  111. it( '#1', () => {
  112. testDataProcessor( '___', '<hr></hr>', '---' );
  113. } );
  114. it( '#2', () => {
  115. testDataProcessor( ' ___', '<hr></hr>', '---' );
  116. } );
  117. it( '#3', () => {
  118. testDataProcessor( ' ___', '<hr></hr>', '---' );
  119. } );
  120. it( '#4', () => {
  121. testDataProcessor( ' ___', '<hr></hr>', '---' );
  122. } );
  123. it( '#5 - code', () => {
  124. testDataProcessor(
  125. ' ___',
  126. // Four spaces are interpreted as code block.
  127. '<pre><code>___</code></pre>',
  128. // Code block will be normalized to ``` representation.
  129. '```\n' +
  130. '___\n' +
  131. '```'
  132. );
  133. } );
  134. } );
  135. describe( 'underscores with spaces', () => {
  136. it( '#1', () => {
  137. testDataProcessor( '_ _ _', '<hr></hr>', '---' );
  138. } );
  139. it( '#2', () => {
  140. testDataProcessor( ' _ _ _', '<hr></hr>', '---' );
  141. } );
  142. it( '#3', () => {
  143. testDataProcessor( ' _ _ _', '<hr></hr>', '---' );
  144. } );
  145. it( '#4', () => {
  146. testDataProcessor( ' _ _ _', '<hr></hr>', '---' );
  147. } );
  148. it( '#5 - code', () => {
  149. testDataProcessor(
  150. ' _ _ _',
  151. // Four spaces are interpreted as code block.
  152. '<pre><code>_ _ _</code></pre>',
  153. // Code block will be normalized to ``` representation.
  154. '```\n' +
  155. '_ _ _\n' +
  156. '```'
  157. );
  158. } );
  159. } );
  160. } );
  161. } );