denshoch/harusame

Add special HTML classes for Tate-Chu-Yoko and text-orientaion.


License
MIT

Documentation

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