Skip to content

Commit

Permalink
DIGITAL-379: Clean up header HTML for incoming content.
Browse files Browse the repository at this point in the history
  • Loading branch information
omerida committed Mar 5, 2025
1 parent 7d15cb7 commit e84be6d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/modules/custom/convert_text/src/ConvertText.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ protected static function afterMigrate(string $source_text, string $field_type):
* Cleans up the markdown to prevent conversion bugs.
*/
protected static function prepareMarkdown(string $source_text): string {
// Targeted fixes to insure incoming HTML isn't mistaken for indented code.
$source_text = preg_replace('/\/svg>(\R|\s)+([A-Za-z0-9]+)/', '/svg>$2', $source_text);
// Remove any line breaks, whitespace before a closing heading.
$source_text = preg_replace('/(\R+|\s+)(<\/h[0-9]+>)/i', '$2', $source_text);

// When the source text has raw HTML, leading spaces are mistaken for
// code blocks.
$lines = array_map(function (string $line): string {
Expand Down

0 comments on commit e84be6d

Please sign in to comment.