# HG changeset patch # User Dan Fuhry # Date 1290155435 18000 # Node ID 61d87ee12e80ae7baa8faac4f086f3260389abd4 # Parent 2a5845ef8c1d29ff3b8505008a16d8d376a0bf9c Added conflict resolution for wikitext heading names diff -r 2a5845ef8c1d -r 61d87ee12e80 includes/wikiengine/render_xhtml.php --- a/includes/wikiengine/render_xhtml.php Fri Nov 19 02:47:10 2010 -0500 +++ b/includes/wikiengine/render_xhtml.php Fri Nov 19 03:30:35 2010 -0500 @@ -26,11 +26,23 @@ public function heading($text, $pieces) { + static $heading_names = array(); foreach ( $pieces as $i => $piece ) { $tocid = sanitize_page_id(trim($piece['text'])); // (bad) workaround for links in headings $tocid = str_replace(array('[', ']'), '', $tocid); + // conflict avoidance + if ( isset($heading_names[$tocid]) ) + { + $id = 2; + while ( isset($heading_names["{$tocid}{$id}"]) ) + $id++; + + $tocid .= $id; + } + $heading_names[$tocid] = true; + $tag = ''; $tag .= trim($piece['text']); $tag .= '';