Implemented some of Enhanced Ordered Lists: numerically ordered lists
now start with the first number given. For example, if you start your list in Markdown as follows: 2. second list item 3. third list item then Markdown will produce this: <ol start="2"> <li>second list item</li> <li>third list item</li> </ol>
This commit is contained in:
parent
53f6388717
commit
b4995d75b8
1 changed files with 12 additions and 1 deletions
|
|
@ -851,16 +851,27 @@ class Markdown {
|
|||
$marker_ul_re = '[*+-]';
|
||||
$marker_ol_re = '\d+[\.]';
|
||||
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
|
||||
$marker_ol_start_re = '[0-9]+';
|
||||
|
||||
$list = $matches[1];
|
||||
$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
|
||||
|
||||
$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
|
||||
|
||||
# Get the start number for ordered list.
|
||||
$ol_start = 1;
|
||||
if ($list_type == 'ol') {
|
||||
$ol_start_array = array();
|
||||
$ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
|
||||
if ($ol_start_check){
|
||||
$ol_start = $ol_start_array[0];
|
||||
}
|
||||
}
|
||||
|
||||
$list .= "\n";
|
||||
$result = $this->processListItems($list, $marker_any_re);
|
||||
|
||||
$result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>");
|
||||
$result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "</$list_type>");
|
||||
return "\n". $result ."\n\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue