假设我想创建标记来转换它:
Some text. SHOUTY Hello. Some more text.
进入这个:
Some text. HELLO! Some more text.
我会用下面的 PHP 做到这一点:
Markup('SHOUTY', 'directives',
'/SHOUTY\\s*(.+?)\\./gs',
'MarkupSHOUTY');
function MarkupSHOUTY($matches) {
return mb_strtoupper($matches[1]) . '!';
}
这适用于上面的幼稚测试用例,但在实际使用中失败:
This is SHOUTY Sparta.
SHOUTY He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum tree,
And stood awhile in thought.
Don't press the button. SHOUTY Don't press it.
变成
This is SPARTA!
SHOUTY He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum tree,
And stood awhile in thought.
Don't press the button. DON'T PRESS IT!
如何在 PmWiki 中创建多行标记?