Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 1.1 as ordered list, rid off PHP warnings #91

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions Michelf/Markdown.php
Expand Up @@ -788,7 +788,7 @@ protected function doLists($text) {

# Re-usable patterns to match list item bullets and number markers:
$marker_ul_re = '[*+-]';
$marker_ol_re = '\d+[\.]';
$marker_ol_re = '\d+[\.][0-9A-Za-z\.]*';
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";

$markers_relist = array(
Expand Down Expand Up @@ -849,7 +849,7 @@ protected function doLists($text) {
protected function _doLists_callback($matches) {
# Re-usable patterns to match list item bullets and number markers:
$marker_ul_re = '[*+-]';
$marker_ol_re = '\d+[\.]';
$marker_ol_re = '\d+[\.][0-9A-Za-z\.]*';
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";

$list = $matches[1];
Expand Down Expand Up @@ -2597,8 +2597,10 @@ protected function _doTable_callback($matches) {
$text = "<table>\n";
$text .= "<thead>\n";
$text .= "<tr>\n";
foreach ($headers as $n => $header)
$text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n";
foreach ($headers as $n => $header) {
$tmp = @$attr[$n];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I checked, the error suppression operator (@) is very slow. Please don't use it, especially in a loop.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I often use a reference assignment in those cases were reference semantics don't get in the way. There are plenty of those in PHP Markdown. Might be a better solution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you can do this way instead
$tmp = isset($attr[$n])?$attr[$n]:'';

$text .= " <th$tmp>".$this->runSpanGamut(trim($header))."</th>\n";
}
$text .= "</tr>\n";
$text .= "</thead>\n";

Expand All @@ -2616,8 +2618,10 @@ protected function _doTable_callback($matches) {
$row_cells = array_pad($row_cells, $col_count, '');

$text .= "<tr>\n";
foreach ($row_cells as $n => $cell)
$text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n";
foreach ($row_cells as $n => $cell) {
$tmp = @$attr[$n];
$text .= " <td$tmp>".$this->runSpanGamut(trim($cell))."</td>\n";
}
$text .= "</tr>\n";
}
$text .= "</tbody>\n";
Expand Down