# HG changeset patch # User Dan # Date 1222691209 14400 # Node ID 29663506e85cbfcf0f5f23f33ab5484df678de37 # Parent 2f1706c4231f73943639175bb8e5256eae562698 Added ability to use hash marks in internal links diff -r 2f1706c4231f -r 29663506e85c includes/render.php --- a/includes/render.php Mon Sep 29 08:26:21 2008 -0400 +++ b/includes/render.php Mon Sep 29 08:26:49 2008 -0400 @@ -271,6 +271,17 @@ eval($cmd); } + //$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; + $template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU"; + $i = 0; + while ( preg_match($template_regex, $text) ) + { + $i++; + if ( $i == 5 ) + break; + $text = RenderMan::include_templates($text); + } + if ( !$plaintext ) { // Process images @@ -287,17 +298,6 @@ } } - //$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is"; - $template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU"; - $i = 0; - while ( preg_match($template_regex, $text) ) - { - $i++; - if ( $i == 5 ) - break; - $text = RenderMan::include_templates($text); - } - // Before shipping it out to the renderer, replace spaces in between headings and paragraphs: $text = preg_replace('/<\/(h[0-9]|div|p)>([\s]+)<(h[0-9]|div|p)( .+?)?>/i', '<\\3\\4>', $text); @@ -495,9 +495,18 @@ foreach ( $matches[0] as $i => $match ) { list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]); + if ( ($pos = strrpos($page_id, '#')) !== false ) + { + $hash = substr($page_id, $pos); + $page_id = substr($page_id, 0, $pos); + } + else + { + $hash = ''; + } $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id); - $url = makeUrl($pid_clean, false, true); + $url = makeUrl($pid_clean, false, true) . $hash; $inner_text = $matches[2][$i]; $quot = '"'; $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';