#author("2021-12-11T01:25:50+09:00","","")
#author("2021-12-11T01:26:08+09:00","","")
* 表組みの書式指定行構文に「太字」の追加 [#o3f40b36]

- ページ: [[BugTrack]]
- 投稿者: [[こん]]
- 優先順位: 低
- 状態: 完了
- カテゴリー: 本体新機能
- 投稿日: 2020-10-23 (金) 22:00:21
- バージョン: 1.5.3
- リリース予定バージョン: 1.5.4

** メッセージ [#xf71cc2f]
現在表組みの書式指定行にサポートされているのは

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

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

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

** 実装 [#qc44213e]
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];
 			}
 		}
*** ついでにユーザー定義も追加 [#kc0df525]
 $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>',
 );
--------
- もし、実装したいならこのようにすると可能です。 -- [[はいふん]] &new{2021-12-06 (月) 23:49:48};
- BOLDとTHは結構違うので、THは[[BugTrack/2531]]に分離しました -- [[umorigu]] &new{2021-12-10 (金) 23:11:20};
- はいふんさんの実装を参考にして、表組みの BOLD: を対応しました commit:70a3f34a0a -- [[umorigu]] &new{2021-12-11 (土) 00:44:21};
- 参考実装はBOLD以外のITALIC等も入れていただいてたのですね。ありがとうございます。複雑化を避けるために、いったんBOLDだけの追加としました。また、「ユーザー定義」ですが、これはマニュアル [[FormattingRules]] に載っていない記法なので、今から追加するのもどうかと思い、見送っています。 PukiWiki 1.3 互換の書き方なのでしょうか? -- [[umorigu]] &new{2021-12-11 (土) 00:59:28};
//やっぱりありました。-- https&#58;//ja.osdn.net/projects/pukiwiki/downloads/12955/pukiwiki-1.3.7.zip/からPukiWiki 1.3.7をダウンロードして軽く確認したところ、default.ini.php自体がなくcolorプラグインといった装飾系のプラグインも含まれてないみたいですね。 -- [[はいふん]] &new{2021-12-11 (土) 01:22:43}; 

#comment

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Site admin: PukiWiki Development Team

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

SourceForge