", pre-formatted text "
", and the various list elements: "
" element is not allowed to contain any other block-level elements. Also
,
function wtm_preformatted($line, &$trfrm) { if (preg_match("/^\s+/", $line)) { $line = $trfrm->SetHTMLMode('pre') . $line; } return $line; } // mode: headings, i.e.,
,
// lines starting with !,!!,!!! are headings function wtm_headings($line, &$trfrm) { if (preg_match("/^(!{1,3})[^!]/", $line, $whichheading)) { if($whichheading[1] == '!') $heading = 'h3'; elseif($whichheading[1] == '!!') $heading = 'h2'; elseif($whichheading[1] == '!!!') $heading = 'h1'; $line = preg_replace("/^!+/", '', $line); $line = $trfrm->SetHTMLMode($heading) . $line; } return $line; } // markup for tables function wtm_table($line, &$trfrm) { $row = ''; while (preg_match('/^(\|+)(v*)([<>^]?)([^|]*)/', $line, $m)) { $line = substr($line, strlen($m[0])); $td = array(); if (strlen($m[1]) > 1) $td['colspan'] = strlen($m[1]); if (strlen($m[2]) > 0) $td['rowspan'] = strlen($m[2]) + 1; if ($m[3] == '^') $td['align'] = 'center'; else if ($m[3] == '>') $td['align'] = 'right'; else $td['align'] = 'left'; $row .= $trfrm->token(StartTag('td', $td) . " "); $row .= trim($m[4]); $row .= $trfrm->token(" "); } assert(empty($line)); $row = $trfrm->token("
") . $row . $trfrm->token(" "); return $trfrm->SetHTMLMode(array('table', array(//'align' => 'left', 'cellpadding' => 1, 'cellspacing' => 1, 'border' => 1))) . $row; } // four or more dashes to
// Note this is of type WT_MODE_MARKUP becuase
's aren't // allowed within's. (e.g. "
" is not valid HTML.) function wtm_hr($line, &$trfrm) { if (preg_match('/^-{4,}(.*)$/', $line, $m)) { $line = $trfrm->SetHTMLMode('', 0) . '
'; if ($m[1]) $line .= $trfrm->SetHTMLMode('p') . $m[1]; } return $line; } // default mode: simple text paragraph function wtm_paragraph($line, &$trfrm) { $line = $trfrm->SetHTMLMode('p') . $line; return $line; } // For emacs users // Local Variables: // mode: php // c-file-style: "ellemtel" // End: ?>