- Issue created by @GuillaumeDuveau
- 🇫🇷France GuillaumeDuveau Toulouse
Actually it's already possible:
/** * Implements hook_markdownify_entity_html_alter(). */ function mymodule_markdownify_entity_html_alter(string &$html, array $context): void { $entity = $context['entity']; if ($entity && $entity->getEntityTypeId() === 'node') { $url = $entity->toUrl('canonical', ['absolute' => TRUE])->toString(); $host = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST); $html = preg_replace_callback( '#(src|href)=["\'](/[^"\']+)["\']#', fn($m) => $m[1] . '="' . $host . $m[2] . '"', $html ); $source = '<p>Source: ' . $url . '</p>'; $html = $source . $html; } }
Here I'm adding the source URL and absolute links.