Harusame
Wrap sequence of numbers(default is two-digit) and sequence of EXCLAMATION (QUESTION) MARKs with span.tcy
in (see Tate-Chu-Yoko).
Wrap each characters of upright glyph orientation with span.upright
and sideways glyph orientation with span.sideways
(see UTR50).
Expected CSS;
.tcy {
text-combine-upright: all;
}
.upright {
text-orientation: upright;
}
.sideways {
text-orientation: sideways;
}
Install
composer install
Usage
$harusame = new Denshoch\Harusame();
$harusame.transform('ๅนณๆ20ๅนด!?');
// => ๅนณๆ<span class="tcy">20</span>ๅนด<span class="tcy">!?</span>
$harusame.transform('<html><head><title>ๅนณๆ20ๅนด!?</title></head><body>ๅนณๆ20ๅนด!?</body></html>');
// You can pass HTML string. Only text nodes within the body tag are transformed.
// => <html><head><title>ๅนณๆ20ๅนด!?</title></head><body>ๅนณๆ<span class="tcy">20</span>ๅนด<span class="tcy">!?</span></body></html>
$harusame.transform('โตโรทโด');
// => <span class="upright">โต</span><span class="upright">โ</span><span class="sideways">รท</span><span class="sideways">โด</span>
Options
$options = array("tcyDigit" => 3);
$harusame = new Denshoch\Harusame($options);
$harusame.transform('10ๅ็ใจ100ๅ็ใใใใ');
// => <span class="tcy">10</span>ๅ็ใจ<span class="tcy">100</span>ๅ็ใใใใ
// or
$harusame = new Denshoch\Harusame();
$harusame.tcyDigit = 3;
$harusame.transform('10ๅ็ใจ100ๅ็ใใใใ');
// => <span class="tcy">10</span>ๅ็ใจ<span class="tcy">100</span>ๅ็ใใใใ
key | type | inital | description |
---|---|---|---|
autoTcy | boolean | true | Add .tcy class or not. |
tcyDigit | integer | 2 | max digits of number to add .tcy class. |
autoTextOrientation | boolean | true | Add .upright and .sideways class or not. |
Test
$ verdor/bin/phpunit