includes/wikiengine/render_xhtml.php
changeset 1329 61d87ee12e80
parent 1227 bdac73ed481e
--- 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 = '<h' . $piece['level'] . ' id="head:' . $tocid . '">';
 			$tag .= trim($piece['text']);
 			$tag .= '</h' . $piece['level'] . '>';