8
0

strong-emphasis.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. describe( 'strong and emphasis', () => {
  8. it( 'should process strong', () => {
  9. testDataProcessor(
  10. '**this is strong** and __this too__',
  11. '<p><strong>this is strong</strong> and <strong>this too</strong></p>',
  12. // When converting back strong will always be represented by **.
  13. '**this is strong** and **this too**'
  14. );
  15. } );
  16. it( 'should process emphasis', () => {
  17. testDataProcessor(
  18. '*this is emphasis* and _this too_',
  19. '<p><em>this is emphasis</em> and <em>this too</em></p>',
  20. // When converting back emphasis will always be represented by __.
  21. '_this is emphasis_ and _this too_'
  22. );
  23. } );
  24. it( 'should process strong and emphasis together #1', () => {
  25. testDataProcessor(
  26. '***This is strong and em.***',
  27. '<p><strong><em>This is strong and em.</em></strong></p>',
  28. // Normalized after converting back.
  29. '**_This is strong and em._**'
  30. );
  31. } );
  32. it( 'should process strong and emphasis together #2', () => {
  33. testDataProcessor(
  34. 'Single ***word*** is strong and em.',
  35. '<p>Single <strong><em>word</em></strong> is strong and em.</p>',
  36. // Normalized after converting back.
  37. 'Single **_word_** is strong and em.'
  38. );
  39. } );
  40. it( 'should process strong and emphasis together #3', () => {
  41. testDataProcessor(
  42. '___This is strong and em.___',
  43. '<p><strong><em>This is strong and em.</em></strong></p>',
  44. // Normalized after converting back.
  45. '**_This is strong and em._**'
  46. );
  47. } );
  48. it( 'should process strong and emphasis together #4', () => {
  49. testDataProcessor(
  50. 'Single ___word___ is strong and em.',
  51. '<p>Single <strong><em>word</em></strong> is strong and em.</p>',
  52. // Normalized after converting back.
  53. 'Single **_word_** is strong and em.'
  54. );
  55. } );
  56. it( 'should not process emphasis inside words', () => {
  57. testDataProcessor(
  58. 'This should_not_be_emp.',
  59. '<p>This should_not_be_emp.</p>',
  60. // Turndow escape markdown markup characters used inside text.
  61. 'This should\\_not\\_be\\_emp.'
  62. );
  63. } );
  64. it( 'should not render escape marks', () => {
  65. testDataProcessor(
  66. // Following the previous test.
  67. 'This should\\_not\\_be\\_emp.',
  68. '<p>This should_not_be_emp.</p>'
  69. );
  70. } );
  71. // Below two tests are not working because marked library renders nested emphasis differently than
  72. // it is done on GitHub.
  73. // it( 'should process nested emphasis #1', () => {
  74. // testDataProcessor(
  75. // '*test **test** test*',
  76. //
  77. // // GitHub is rendering as:
  78. // // <p><em>test *</em>test** test*</p>
  79. //
  80. // '<p><em>test *</em>test** test*</p>'
  81. // );
  82. // } );
  83. // it( 'should process nested emphasis #2', () => {
  84. // testDataProcessor(
  85. // '_test __test__ test_',
  86. //
  87. // // GitHub is rendering as:
  88. // '<p><em>test __test_</em> test_</p>'
  89. // );
  90. // } );
  91. } );
  92. } );