denshoch / harusame
Add special HTML classes for Tate-Chu-Yoko and text-orientaion.
2.1.3
2020-11-02 01:42 UTC
Requires (Dev)
- phpunit/phpunit: >=6.5.13
README
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