From e5a7c782a8b735c2076522563cfc37d9718be514 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Sun, 9 Nov 2008 08:47:42 -0500 Subject: [PATCH 1/8] Fixed a few typos. --- markdown.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/markdown.php b/markdown.php index 8179b56..43ca68e 100644 --- a/markdown.php +++ b/markdown.php @@ -691,12 +691,12 @@ class Markdown_Parser { \) ) }xs', - array(&$this, '_DoAnchors_inline_callback'), $text); + array(&$this, '_doAnchors_inline_callback'), $text); # # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link test][1] - # or [link test](/foo) + # These must come last in case you've also got [link text][1] + # or [link text](/foo) # // $text = preg_replace_callback('{ // ( # wrap whole match in $1 @@ -1121,7 +1121,7 @@ class Markdown_Parser { function prepareItalicsAndBold() { # - # Prepare regular expressions for seraching emphasis tokens in any + # Prepare regular expressions for searching emphasis tokens in any # context. # foreach ($this->em_relist as $em => $em_re) { @@ -1156,7 +1156,7 @@ class Markdown_Parser { $token_re = $this->em_strong_prepared_relist["$em$strong"]; # - # Each loop iteration seach for the next emphasis token. + # Each loop iteration search for the next emphasis token. # Each token is then passed to handleSpanToken. # $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); @@ -1289,7 +1289,7 @@ class Markdown_Parser { # These leading spaces cause problem with
 content, 
 		# so we need to fix that:
 		$bq = preg_replace_callback('{(\s*
.+?
)}sx', - array(&$this, '_DoBlockQuotes_callback2'), $bq); + array(&$this, '_doBlockQuotes_callback2'), $bq); return "\n". $this->hashBlock("
\n$bq\n
")."\n\n"; } From 9b21cc6adf394b3ad6d5da2b786a53d6bf00c73d Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 31 Dec 2008 21:51:10 -0500 Subject: [PATCH 2/8] Now accepting all valid email addresses in automatic links. --- markdown.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/markdown.php b/markdown.php index 43ca68e..96b7418 100644 --- a/markdown.php +++ b/markdown.php @@ -1411,9 +1411,17 @@ class Markdown_Parser { < (?:mailto:)? ( - [-.\w\x80-\xFF]+ + (?: + [-!#$%&\'*+/=?^_`.{|}~\w\x80-\xFF]+ + | + ".*?" + ) \@ - [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+ + (?: + [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+ + | + \[[\d.a-fA-F:]+\] # IPv4 & IPv6 + ) ) > }xi', From bf6366481e68fc05301becbeef3fc292832f29af Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 31 Dec 2008 21:51:41 -0500 Subject: [PATCH 3/8] Now accepting spaces inside angle-bracked-delimited URLs in inline and reference links. --- markdown.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/markdown.php b/markdown.php index 96b7418..b61a942 100644 --- a/markdown.php +++ b/markdown.php @@ -332,14 +332,18 @@ class Markdown_Parser { [ ]* \n? # maybe *one* newline [ ]* - ? # url = $2 + (?: + <(.+?)> # url = $2 + | + (\S+?) # url = $3 + ) [ ]* \n? # maybe one newline [ ]* (?: (?<=\s) # lookbehind for whitespace ["(] - (.*?) # title = $3 + (.*?) # title = $4 [")] [ ]* )? # title is optional @@ -351,8 +355,9 @@ class Markdown_Parser { } function _stripLinkDefinitions_callback($matches) { $link_id = strtolower($matches[1]); - $this->urls[$link_id] = $matches[2]; - $this->titles[$link_id] =& $matches[3]; + $url = $matches[2] == '' ? $matches[3] : $matches[2]; + $this->urls[$link_id] = $url; + $this->titles[$link_id] =& $matches[4]; return ''; # String that will replace the block } @@ -677,7 +682,7 @@ class Markdown_Parser { \( # literal paren [ ]* (?: - <(\S*)> # href = $3 + <(.+?)> # href = $3 | ('.$this->nested_url_parenthesis_re.') # href = $4 ) From 4bd7facc2bbf68cf20b7ca7b56e8dc75a3b85495 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Thu, 1 Jan 2009 09:29:26 -0500 Subject: [PATCH 4/8] Fix for adjacent list of different kind. --- PHP Markdown Readme.text | 6 ++++++ markdown.php | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index 2778f5e..958728f 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -200,6 +200,12 @@ expected; (3) the output PHP Markdown actually produced. Version History --------------- +Current: + +* Fix for adjacent list of different kind where the second list could + end as a sublist of the first when not separated by an empty line. + + 1.0.1m (21 Jun 2008): * Lists can now have empty items. diff --git a/markdown.php b/markdown.php index b61a942..c976e82 100644 --- a/markdown.php +++ b/markdown.php @@ -929,19 +929,22 @@ class Markdown_Parser { $marker_ol_re = '\d+[.]'; $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; - $markers_relist = array($marker_ul_re, $marker_ol_re); + $markers_relist = array( + $marker_ul_re => $marker_ol_re, + $marker_ol_re => $marker_ul_re, + ); - foreach ($markers_relist as $marker_re) { + foreach ($markers_relist as $marker_re => $other_marker_re) { # Re-usable pattern to match any entirel ul or ol list: $whole_list_re = ' ( # $1 = whole list ( # $2 - [ ]{0,'.$less_than_tab.'} - ('.$marker_re.') # $3 = first list item marker + ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces + ('.$marker_re.') # $4 = first list item marker [ ]+ ) (?s:.+?) - ( # $4 + ( # $5 \z | \n{2,} @@ -950,6 +953,12 @@ class Markdown_Parser { [ ]* '.$marker_re.'[ ]+ ) + | + (?= # Lookahead for another kind of list + \n + \3 # Must have the same indentation + '.$other_marker_re.'[ ]+ + ) ) ) '; // mx @@ -982,7 +991,7 @@ class Markdown_Parser { $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; $list = $matches[1]; - $list_type = preg_match("/$marker_ul_re/", $matches[3]) ? "ul" : "ol"; + $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); From 76d4ba85c6960b47b4f1e99c7ebda5787060c86e Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Thu, 1 Jan 2009 09:36:59 -0500 Subject: [PATCH 5/8] Added missing changelog entry. --- PHP Markdown Readme.text | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index 958728f..d0d5be6 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -205,6 +205,15 @@ Current: * Fix for adjacent list of different kind where the second list could end as a sublist of the first when not separated by an empty line. +* Now accepting many valid email addresses in autolinks that were + previously rejected, such as: + + + + <"abc@def"@example.com> + <"Fred Bloggs"@example.com> + + 1.0.1m (21 Jun 2008): From cffcfe4e93083ed89c664e4e74e2afb8f7e7342a Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Thu, 1 Jan 2009 09:43:37 -0500 Subject: [PATCH 6/8] Added another missing changelog entry for URLs containing spaces. --- PHP Markdown Readme.text | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index d0d5be6..dade9ca 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -214,6 +214,17 @@ Current: <"Fred Bloggs"@example.com> +* Now accepting spaces in URLs for inline and reference-style links. Such + URLs need to be surrounded by angle brakets. For instance: + + [link text]( "optional title") + + [link text][ref] + [ref]: "optional title" + + There is still a quirk which may prevent this from working correctly with + relative URLs in inline-style links however. + 1.0.1m (21 Jun 2008): From b820a9a14d4d0fbb6ad4e16470b4979c33314164 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Wed, 30 Sep 2009 23:41:31 -0400 Subject: [PATCH 7/8] Now allowing newlines inside inline-style link definitions. --- PHP Markdown Readme.text | 3 +++ markdown.php | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index dade9ca..ba2340f 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -225,6 +225,9 @@ Current: There is still a quirk which may prevent this from working correctly with relative URLs in inline-style links however. +* Fixed a bug where inline-style links wouldn't be recognized when the link + definition contains a line break between the url and the title. + 1.0.1m (21 Jun 2008): diff --git a/markdown.php b/markdown.php index c976e82..0eed6e8 100644 --- a/markdown.php +++ b/markdown.php @@ -680,18 +680,18 @@ class Markdown_Parser { ('.$this->nested_brackets_re.') # link text = $2 \] \( # literal paren - [ ]* + [ \n]* (?: <(.+?)> # href = $3 | ('.$this->nested_url_parenthesis_re.') # href = $4 ) - [ ]* + [ \n]* ( # $5 ([\'"]) # quote char = $6 (.*?) # Title = $7 \6 # matching quote - [ ]* # ignore any spaces/tabs between closing quote and ) + [ \n]* # ignore any spaces/tabs between closing quote and ) )? # title is optional \) ) @@ -805,18 +805,18 @@ class Markdown_Parser { \] \s? # One optional whitespace character \( # literal paren - [ ]* + [ \n]* (?: <(\S*)> # src url = $3 | ('.$this->nested_url_parenthesis_re.') # src url = $4 ) - [ ]* + [ \n]* ( # $5 ([\'"]) # quote char = $6 (.*?) # title = $7 \6 # matching quote - [ ]* + [ \n]* )? # title is optional \) ) From d64613d64a0fb243ac9fca61877e0a8207248000 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Thu, 1 Oct 2009 09:05:58 -0400 Subject: [PATCH 8/8] Fix for tags with underscore. --- PHP Markdown Readme.text | 3 +++ markdown.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index ba2340f..528eb50 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -228,6 +228,9 @@ Current: * Fixed a bug where inline-style links wouldn't be recognized when the link definition contains a line break between the url and the title. +* Fixed a bug where tags where the name contains an underscore aren't parsed + correctly. + 1.0.1m (21 Jun 2008): diff --git a/markdown.php b/markdown.php index 0eed6e8..7c0d7f8 100644 --- a/markdown.php +++ b/markdown.php @@ -1515,7 +1515,7 @@ class Markdown_Parser { | <\?.*?\?> | <%.*?%> # processing instruction | - <[/!$]?[-a-zA-Z0-9:]+ # regular tags + <[/!$]?[-a-zA-Z0-9:_]+ # regular tags (?> \s (?>[^"\'>]+|"[^"]*"|\'[^\']*\')*