Loading core/lib/Drupal/Core/Mail/MailFormatHelper.php +0 −9 Original line number Diff line number Diff line Loading @@ -142,8 +142,6 @@ public static function htmlToText($string, $allowed_tags = NULL) { // required). // Odd/even counter (tag or no tag). $tag = FALSE; // Case conversion function. $casing = NULL; $output = ''; // All current indentation string chunks. $indent = []; Loading Loading @@ -221,17 +219,14 @@ public static function htmlToText($string, $allowed_tags = NULL) { // Fancy headers. case 'h1': $indent[] = '======== '; $casing = 'mb_strtoupper'; break; case 'h2': $indent[] = '-------- '; $casing = 'mb_strtoupper'; break; case '/h1': case '/h2': $casing = NULL; // Pad the line with dashes. $output = static::htmlToTextPad($output, ($tagname == '/h1') ? '=' : '-', ' '); array_pop($indent); Loading Loading @@ -266,10 +261,6 @@ public static function htmlToText($string, $allowed_tags = NULL) { // See if there is something waiting to be output. if (isset($chunk)) { // Apply any necessary case conversion. if (isset($casing)) { $chunk = call_user_func($casing, $chunk); } $line_endings = Settings::get('mail_line_endings', PHP_EOL); // Format it and apply the current indentation. $output .= static::wrapMail($chunk, implode('', $indent)) . $line_endings; Loading core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php +8 −8 Original line number Diff line number Diff line Loading @@ -85,10 +85,10 @@ public function testTags() { // @todo The <div> tag is currently not supported. '<div>Drupal</div><div>Drupal</div>' => "DrupalDrupal\n", '<em>Drupal</em>' => "/Drupal/\n", '<h1>Drupal</h1>' => "======== DRUPAL ==============================================================\n\n", '<h1>Drupal</h1><p>Drupal</p>' => "======== DRUPAL ==============================================================\n\nDrupal\n\n", '<h2>Drupal</h2>' => "-------- DRUPAL --------------------------------------------------------------\n\n", '<h2>Drupal</h2><p>Drupal</p>' => "-------- DRUPAL --------------------------------------------------------------\n\nDrupal\n\n", '<h1>Drupal</h1>' => "======== Drupal ==============================================================\n\n", '<h1>Drupal</h1><p>Drupal</p>' => "======== Drupal ==============================================================\n\nDrupal\n\n", '<h2>Drupal</h2>' => "-------- Drupal --------------------------------------------------------------\n\n", '<h2>Drupal</h2><p>Drupal</p>' => "-------- Drupal --------------------------------------------------------------\n\nDrupal\n\n", '<h3>Drupal</h3>' => ".... Drupal\n\n", '<h3>Drupal</h3><p>Drupal</p>' => ".... Drupal\n\nDrupal\n\n", '<h4>Drupal</h4>' => ".. Drupal\n\n", Loading Loading @@ -247,21 +247,21 @@ public function testDrupalHtmlToTextBlockTagToNewline() { public function testHeaderSeparation() { $html = 'Drupal<h1>Drupal</h1>Drupal'; // @todo There should be more space above the header than below it. $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n"; $text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n"; $this->assertHtmlToText($html, $text, 'Text before and after <h1> tag'); $html = '<p>Drupal</p><h1>Drupal</h1>Drupal'; // @todo There should be more space above the header than below it. $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n"; $text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n"; $this->assertHtmlToText($html, $text, 'Paragraph before and text after <h1> tag'); $html = 'Drupal<h1>Drupal</h1><p>Drupal</p>'; // @todo There should be more space above the header than below it. $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n\n"; $text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n\n"; $this->assertHtmlToText($html, $text, 'Text before and paragraph after <h1> tag'); $html = '<p>Drupal</p><h1>Drupal</h1><p>Drupal</p>'; $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n\n"; $text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n\n"; $this->assertHtmlToText($html, $text, 'Paragraph before and after <h1> tag'); } Loading Loading
core/lib/Drupal/Core/Mail/MailFormatHelper.php +0 −9 Original line number Diff line number Diff line Loading @@ -142,8 +142,6 @@ public static function htmlToText($string, $allowed_tags = NULL) { // required). // Odd/even counter (tag or no tag). $tag = FALSE; // Case conversion function. $casing = NULL; $output = ''; // All current indentation string chunks. $indent = []; Loading Loading @@ -221,17 +219,14 @@ public static function htmlToText($string, $allowed_tags = NULL) { // Fancy headers. case 'h1': $indent[] = '======== '; $casing = 'mb_strtoupper'; break; case 'h2': $indent[] = '-------- '; $casing = 'mb_strtoupper'; break; case '/h1': case '/h2': $casing = NULL; // Pad the line with dashes. $output = static::htmlToTextPad($output, ($tagname == '/h1') ? '=' : '-', ' '); array_pop($indent); Loading Loading @@ -266,10 +261,6 @@ public static function htmlToText($string, $allowed_tags = NULL) { // See if there is something waiting to be output. if (isset($chunk)) { // Apply any necessary case conversion. if (isset($casing)) { $chunk = call_user_func($casing, $chunk); } $line_endings = Settings::get('mail_line_endings', PHP_EOL); // Format it and apply the current indentation. $output .= static::wrapMail($chunk, implode('', $indent)) . $line_endings; Loading
core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php +8 −8 Original line number Diff line number Diff line Loading @@ -85,10 +85,10 @@ public function testTags() { // @todo The <div> tag is currently not supported. '<div>Drupal</div><div>Drupal</div>' => "DrupalDrupal\n", '<em>Drupal</em>' => "/Drupal/\n", '<h1>Drupal</h1>' => "======== DRUPAL ==============================================================\n\n", '<h1>Drupal</h1><p>Drupal</p>' => "======== DRUPAL ==============================================================\n\nDrupal\n\n", '<h2>Drupal</h2>' => "-------- DRUPAL --------------------------------------------------------------\n\n", '<h2>Drupal</h2><p>Drupal</p>' => "-------- DRUPAL --------------------------------------------------------------\n\nDrupal\n\n", '<h1>Drupal</h1>' => "======== Drupal ==============================================================\n\n", '<h1>Drupal</h1><p>Drupal</p>' => "======== Drupal ==============================================================\n\nDrupal\n\n", '<h2>Drupal</h2>' => "-------- Drupal --------------------------------------------------------------\n\n", '<h2>Drupal</h2><p>Drupal</p>' => "-------- Drupal --------------------------------------------------------------\n\nDrupal\n\n", '<h3>Drupal</h3>' => ".... Drupal\n\n", '<h3>Drupal</h3><p>Drupal</p>' => ".... Drupal\n\nDrupal\n\n", '<h4>Drupal</h4>' => ".. Drupal\n\n", Loading Loading @@ -247,21 +247,21 @@ public function testDrupalHtmlToTextBlockTagToNewline() { public function testHeaderSeparation() { $html = 'Drupal<h1>Drupal</h1>Drupal'; // @todo There should be more space above the header than below it. $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n"; $text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n"; $this->assertHtmlToText($html, $text, 'Text before and after <h1> tag'); $html = '<p>Drupal</p><h1>Drupal</h1>Drupal'; // @todo There should be more space above the header than below it. $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n"; $text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n"; $this->assertHtmlToText($html, $text, 'Paragraph before and text after <h1> tag'); $html = 'Drupal<h1>Drupal</h1><p>Drupal</p>'; // @todo There should be more space above the header than below it. $text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n\n"; $text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n\n"; $this->assertHtmlToText($html, $text, 'Text before and paragraph after <h1> tag'); $html = '<p>Drupal</p><h1>Drupal</h1><p>Drupal</p>'; $text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n\n"; $text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n\n"; $this->assertHtmlToText($html, $text, 'Paragraph before and after <h1> tag'); } Loading