カテゴリ | |
---|---|
サマリ | BGCOLOR()やCOLOR()の色を追加したい |
バージョン | 1.4.7 |
投稿者 | HsT |
状態 | 質問 |
投稿日 | 2008-12-21 (日) 17:40:41 |
COLOR(red)やBGCOLOR(blue)などで色がつけられますよね?
これの色を追加したいのですがどうすればよいでしょうか?
BGCOLOR(test)の様な感じで追加したいです
#000000などの指定だと多用すると編集画面が見難くなったりするので解決したいです
さらにbgcolorというのも長いのでBCO(test)のように少し省略できるようにもできませんでしょうか?
できれば文章以外の配色系の色で長い文字列を表示したくなくスッキリさせたいのでご存じの方教えてくださいませ
'CL\(abc\){([^}]*)}' => '<span style="color:#000000">$1</span>', 'BCL\(abc\){([^}]*)}' => '<span style="background-color:#000000">$1</span>',
function TableCell($text, $is_template = FALSE) { parent::Element(); $this->style = $matches = array(); while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)):(.*)$/', $text, $matches)) { if ($matches[1]) { $this->style['align'] = 'text-align:' . strtolower($matches[1]) . ';'; $text = $matches[5]; } else if ($matches[3]) { $name = $matches[2] ? 'background-color' : 'color'; + switch (strtolower($matches[3])) { + case 'test': + $matches[3] = '#000000'; + break; + } + $this->style[$name] = $name . ':' . htmlspecialchars($matches[3]) . ';'; $text = $matches[5]; } else if ($matches[4]) { $this->style['size'] = 'font-size:' . htmlspecialchars($matches[4]) . 'px;'; $text = $matches[5]; } }一応、color プラグインの改造例も。エラーチェックの手前に入れたのは、'黒'→'#000000' と置き換えたりもできる様にです。(後ろに入れると、実質アルファベットしかルール名に使えなくなりますし)
// Invalid color foreach(array($color, $bgcolor) as $col){ + switch (strtolower($matches[3])) { + case 'test': + $matches[3] = '#000000'; + break; + } + if ($col != '' && ! preg_match(PLUGIN_COLOR_REGEX, $col)) return '&color():Invalid color: ' . htmlspecialchars($col) . ';'; } if (PLUGIN_COLOR_ALLOW_CSS === TRUE || ! isset($pkwk_dtd) || $pkwk_dtd == PKWK_DTD_XHTML_1_1) {ところで、表組みに対してだけこの機能を追加しようと考えていたのですか? -- 2009-07-30 (木) 16:07:28