表組みの書式指定行構文に「太字」の追加

メッセージ

現在表組みの書式指定行にサポートされているのは

LEFT:
CENTER:
RIGHT:
BGCOLOR(色):
COLOR(色):
SIZE(サイズ):

の6つだけですが、ここに太字(BOLD:)の追加も希望したいです。

また、これは厳密には書式ではないのですが、見出し(TH:)もあったら便利かなと思います。BugTrack/2531 に移動

実装

525行辺りのwhileを置き換えてみます。

		while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)|(BOLD)|(ITALIC|OBLIQUE)|(UNDERLINE|OVERLINE|LINE-THROUGH)|(TH)):(.*)$/',
		    $text, $matches)) {
			if ($matches[1]) {
				$this->style['align'] = 'text-align:' . strtolower($matches[1]) . ';';
				$text = $matches[9];
			} else if ($matches[3]) {
				$name = $matches[2] ? 'background-color' : 'color';
				$this->style[$name] = $name . ':' . htmlsc($matches[3]) . ';';
				$text = $matches[9];
			} else if ($matches[4]) {
				$this->style['size'] = 'font-size:' . htmlsc($matches[4]) . 'px;';
				$text = $matches[9];
			} else if ($matches[5]) {
				$this->style['bold'] = 'font-weight:bold;';
				$text = $matches[9];
			} else if ($matches[6]) {
				$this->style['style'] = 'font-style:'.strtolower(htmlsc($matches[6])).';';
				$text = $matches[9];
			} else if ($matches[7]) {
				$this->style['decoration'] = 'text-decoration:'.strtolower(htmlsc($matches[7])).';';
				$text = $matches[9];
			} else if ($matches[8]) {
				$this->tag = 'th';
				$text = $matches[9];
			}
		}

ついでにユーザー定義も追加

$line_rules = array(
        'COLOR\(([^\(\)]*)\){([^}]*)}'	=> '<span style="color:$1">$2</span>',
        'SIZE\(([^\(\)]*)\){([^}]*)}'	=> '<span style="font-size:$1px">$2</span>',
        'COLOR\(([^\(\)]*)\):((?:(?!COLOR\([^\)]+\)\:).)*)'	=> '<span style="color:$1">$2</span>',
        'SIZE\(([^\(\)]*)\):((?:(?!SIZE\([^\)]+\)\:).)*)'	=> '<span class="size$1">$2</span>',
        'BOLD:((?:(?!BOLD\([^\)]+\)\:).)*)'	=> '<b>$1</b>',
        'ITALIC:((?:(?!ITALIC\([^\)]+\)\:).)*)'	=> '<i>$1</i>',
        'OBLIQUE:((?:(?!OBLIQUE\([^\)]+\)\:).)*)'	=> '<em>$1</em>',
        'UNDERLINE:((?:(?!UNDERLINE\([^\)]+\)\:).)*)'	=> '<u>$1</u>',
        'OVERLINE:((?:(?!OVERLINE\([^\)]+\)\:).)*)'	=> '<span style="text-decoration: overline;">$1</span>',
        'LINE-THROUGH:((?:(?!LINE-THROUGH\([^\)]+\)\:).)*)'	=> '<span style="text-decoration: line-through;">$1</span>',
        '%%%(?!%)((?:(?!%%%).)*)%%%'	=> '<ins>$1</ins>',
        '%%(?!%)((?:(?!%%).)*)%%'	=> '<del>$1</del>',
        "'''(?!')((?:(?!''').)*)'''"	=> '<em>$1</em>',
        "''(?!')((?:(?!'').)*)''"	=> '<strong>$1</strong>',
);



トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-12-11 (土) 01:26:08
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 0.198 sec.

SourceForge