Permalink
Browse files

Fixed a definition list issue with code block starting a definition.

  • Loading branch information...
michelf committed Mar 11, 2008
1 parent 8cae101 commit a228680cf0048a46869878bed36707cc91de4723
Showing with 12 additions and 7 deletions.
  1. +12 −7 markdown.php
View
@@ -2217,7 +2217,7 @@ function doDefLists($text) {
)'; // mx
$text = preg_replace_callback('{
- (?:(?<=\n\n)|\A\n?)
+ (?>\A\n?|(?<=\n\n))
'.$whole_list.'
}mx',
array(&$this, '_doDefLists_callback'), $text);
@@ -2248,12 +2248,12 @@ function processDefListItems($list_str) {
# Process definition terms.
$list_str = preg_replace_callback('{
- (?:\n\n+|\A\n?) # leading line
+ (?>\A\n?|\n\n+) # leading line
( # definition terms = $1
[ ]{0,'.$less_than_tab.'} # leading whitespace
(?![:][ ]|[ ]) # negative lookahead for a definition
# mark (colon) or more whitespace.
- (?: \S.* \n)+? # actual term (not whitespace).
+ (?> \S.* \n)+? # actual term (not whitespace).
)
(?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
# with a definition mark.
@@ -2263,9 +2263,11 @@ function processDefListItems($list_str) {
# Process actual definitions.
$list_str = preg_replace_callback('{
\n(\n+)? # leading line = $1
- [ ]{0,'.$less_than_tab.'} # whitespace before colon
- [:][ ]+ # definition mark (colon)
- ((?s:.+?)) # definition text = $2
+ ( # marker space = $2
+ [ ]{0,'.$less_than_tab.'} # whitespace before colon
+ [:][ ]+ # definition mark (colon)
+ )
+ ((?s:.+?)) # definition text = $3
(?= \n+ # stop at next definition mark,
(?: # next term or end of text
[ ]{0,'.$less_than_tab.'} [:][ ] |
@@ -2288,9 +2290,12 @@ function _processDefListItems_callback_dt($matches) {
}
function _processDefListItems_callback_dd($matches) {
$leading_line = $matches[1];
- $def = $matches[2];
+ $marker_space = $matches[2];
+ $def = $matches[3];
if ($leading_line || preg_match('/\n{2,}/', $def)) {
+ # Replace marker with the appropriate whitespace indentation
+ $def = str_repeat(' ', strlen($marker_space)) . $def;
$def = $this->runBlockGamut($this->outdent($def . "\n\n"));
$def = "\n". $def ."\n";
}

0 comments on commit a228680

Please sign in to comment.