Index: Parser.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Parser.php,v
retrieving revision 1.252
diff -u -r1.252 Parser.php
--- Parser.php	22 Aug 2004 17:24:50 -0000	1.252
+++ Parser.php	22 Aug 2004 22:39:25 -0000
@@ -578,6 +578,7 @@
 
 		$text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text );
 
+		$text = $this->formatFootnotes( $text );
 		$text = $this->doHeadings( $text );
 		if($this->mOptions->getUseDynamicDates()) {
 			global $wgDateFormatter;
@@ -2051,7 +2052,77 @@
 		}
 	}
 
-	# Return an HTML link for the "ISBN 123456" text
+#<<<<<<< Parser.php
+
+/*
+ *
+ * This function accomplishes several tasks:
+ * 1) Auto-number footnotes
+ * 3) Add a Notes section on the bottom
+ * 4) Auto-anchor footnotes
+ *
+ * It loops through all footnotes, collects the necessary data, then 
+ * splits up the
+ * string and re-inserts the newly formatted headlines.
+ *
+ */
+	/* private */ function formatFootnotes( $text, $isMain=true )
+	{
+
+
+		# numMatches is only used to test if there are footnotes, 
+		#should be better way
+		$numMatches = preg_match_all( '/\[note:(.*?)\]/i', $text, $matches );
+
+		#check if there are any notes
+		if ($numMatches) {
+
+		# To perform operations on the HTML
+		$sk =& $this->mOptions->getSkin();
+		
+		#footnote counter
+		$footnoteCount = 0;
+
+		foreach ( $matches[1] as $footnote ) {
+		  $footnoteCount = $footnoteCount + 1;
+
+		  #format notes that appear in  bottom note section	
+		  $footnotes .= $sk->footLine($footnoteCount, $footnote);
+		  
+		  #replace double quotes with literal for <title=>	
+		  $confootnote = preg_replace( '/"/', '&#34;', $footnote);
+		  $confootnote = preg_replace( '/<.*?' . '>/','', $confootnote );
+		  $confootnote = preg_replace( '/:/', '&#58;', $confootnote );	
+
+		  #format footnote and hold it in refer
+  		  $refer[$footnoteCount] = $sk->footNum($footnoteCount, $confootnote);
+                }
+		
+		#format endnotes section
+		$footnotes = $sk->endNotes($footnotes);
+
+	        $blocks = preg_split( '/\[note:(.*?)\]/i', $text );
+		$i = 0;
+
+		foreach( $blocks as $block ) {
+			$full .= $block;
+
+
+			if( !empty( $refer[$i+1] ) ) {
+				$full .= $refer[$i+1];
+			}
+			$i++;
+		}
+
+		$full .= '<br />'.$footnotes;		
+		return $full;
+		}
+		else {
+		  return $text;
+		    }
+	}
+
+        # Return an HTML link for the "ISBN 123456" text
 	/* private */ function magicISBN( $text ) {
 		global $wgLang;
 		$fname = 'Parser::magicISBN';
