Skip to content

Instantly share code, notes, and snippets.

@sn00011
Created October 19, 2011 08:45
Show Gist options
  • Save sn00011/1297755 to your computer and use it in GitHub Desktop.
Save sn00011/1297755 to your computer and use it in GitHub Desktop.
for issue #37504
diff --git markdown.php markdown.php
index ed79197..0cde939 100644
--- markdown.php
+++ markdown.php
@@ -761,6 +761,17 @@ class Markdown_Parser {
$url = $this->encodeAttribute($url);
+ // For some links like [xxx](/node/xxx), turn them into absolute ones
+ // so when they're contained in feeds, the W3C feed validator won't
+ // complain about the relative urls.
+ // @see issue #37504
+ if (strpos($url, '/') === 0) {
+ // Remove the leading slash
+ $url = ltrim($url, '/');
+ // Use drupal's url() to generate an absolute url
+ $url = url($url, array('absolute' => TRUE));
+ }
+
$result = "<a href=\"$url\"";
if (isset($title)) {
$title = $this->encodeAttribute($title);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment