From 367f394933288a9b05880f20f54719e71d55da3d Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 27 Feb 2008 23:19:19 -0500 Subject: [PATCH 1/4] Fix for begin taken as a HR tag. --- markdown.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/markdown.php b/markdown.php index 49fe027..3b70426 100644 --- a/markdown.php +++ b/markdown.php @@ -434,8 +434,7 @@ class Markdown_Parser { [ ]{0,'.$less_than_tab.'} <(hr) # start tag = $2 - \b # word break - ([^<>])*? # + '.$attr.' # attributes /?> # the matching end tag [ ]* (?=\n{2,}|\Z) # followed by a blank line or end of document From d6d9fe79d53d062631aaa952eab9654edea774f5 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 27 Feb 2008 23:21:03 -0500 Subject: [PATCH 2/4] Fix for capitalized URL schemes in autolinks. --- markdown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown.php b/markdown.php index 3b70426..0313dfb 100644 --- a/markdown.php +++ b/markdown.php @@ -1233,7 +1233,7 @@ class Markdown_Parser { function doAutoLinks($text) { - $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}', + $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i', array(&$this, '_doAutoLinks_url_callback'), $text); # Email addresses: From bfca8fa34fb011f49a2ffea16524d9376f9a5a63 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 27 Feb 2008 23:23:28 -0500 Subject: [PATCH 3/4] Fix for code block starting on the second line of the document. --- markdown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown.php b/markdown.php index 0313dfb..65b73d6 100644 --- a/markdown.php +++ b/markdown.php @@ -1028,7 +1028,7 @@ class Markdown_Parser { # Process Markdown `
` blocks.
 	#
 		$text = preg_replace_callback('{
-				(?:\n\n|\A)
+				(?:\n\n|\A\n?)
 				(	            # $1 = the code block -- one or more lines, starting with a space/tab
 				  (?>
 					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces

From 4596f60a01446a08a2aa14b74c85a2ae07425a98 Mon Sep 17 00:00:00 2001
From: Michel Fortin 
Date: Thu, 28 Feb 2008 06:47:43 -0500
Subject: [PATCH 4/4] Now removing UTF-8 BOM at the start of the document, if
 present.

---
 markdown.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/markdown.php b/markdown.php
index 65b73d6..51a7d22 100644
--- a/markdown.php
+++ b/markdown.php
@@ -254,6 +254,9 @@ class Markdown_Parser {
 		$this->urls = array();
 		$this->titles = array();
 		$this->html_hashes = array();
+		
+		# Remove UTF-8 BOM, if present.
+		$text = preg_replace('{^\xEF\xBB\xBF}', '', $text);
 
 		# Standardize line endings:
 		#   DOS to Unix and Mac to Unix