FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 2e7bef8b authored by Anthony Michaels's avatar Anthony Michaels
Browse files

Remove unused cleanup script

parent 3a3644ff
No related branches found
No related tags found
1 merge request!4Migrate D7 text_block paragraphs to D10 text paragraphs
<?php
namespace Drupal\cambridge_migrations\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* Clean up HTML content by removing unwanted JSON media entries.
*
* @MigrateProcessPlugin(
* id = "clean_html"
* )
*/
class CleanHtml extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (empty($value)) {
return $value;
}
// Remove JSON media entries wrapped in <p> tags
$value = preg_replace('/<p>\[\[{.*?"type":"media".*?}\]\]<\/p>/s', '', $value);
// Remove any standalone JSON media entries
$value = preg_replace('/\[\[{.*?"type":"media".*?}\]\]/s', '', $value);
// Clean up multiple blank lines that might be left after removing content
$value = preg_replace('/(\r?\n){2,}/', "\n\n", $value);
$value = preg_replace('/<p>\s*<\/p>/', '', $value);
return trim($value);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment