// Table: starts with | and next line is separator if (strpos($stripped, '|') === 0 && $i + 1 < count($lines) && preg_match('/^\|[\s|:-]+\|/', trim($lines[$i+1]))) { $close_list(); $header_cells = array_map('trim', explode('|', trim($stripped, '|'))); $i += 2; $rows = []; while ($i < count($lines) && strpos(trim($lines[$i]), '|') === 0) { $row_cells = array_map('trim', explode('|', trim(trim($lines[$i]), '|'))); $rows[] = $row_cells; $i++; } $tbl = ['', '', '']; foreach ($header_cells as $c) $tbl[] = ''; $tbl[] = ''; foreach ($rows as $row) { $tbl[] = ''; foreach ($row as $c) $tbl[] = ''; $tbl[] = ''; } $tbl[] = '
' . $inline($c) . '
' . $inline($c) . '
'; $out[] = implode('', $tbl); continue; } // Ordered list if (preg_match('/^\d+\.\s/', $stripped)) { if ($list_type !== 'ol') { $close_list(); $out[] = '
    '; $in_list = true; $list_type = 'ol'; } $content_item = preg_replace('/^\d+\.\s+/', '', $stripped); $out[] = '
  1. ' . $inline($content_item) . '
  2. '; $i++; continue; } // Unordered list if (strpos($stripped, '- ') === 0) { if ($list_type !== 'ul') { $close_list(); $out[] = '