2017 © Pedro Peláez
 

library harusame

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

image

denshoch/harusame

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

  • Friday, March 3, 2017
  • by denshoch
  • Repository
  • 2 Watchers
  • 0 Stars
  • 159 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Harusame

Harusame is a library designed to control the orientation of characters in vertical writing. It allows for the proper display of text in Japanese vertical format, ensuring that characters are displayed upright or sideways as needed. This is particularly useful for applications that require text to be formatted according to traditional Japanese typesetting standards., (*1)

Wrap sequence of numbers (default is two-digit) and sequence of EXCLAMATION (QUESTION) MARKs with span.tcy in (see Tate-Chu-Yoko)., (*2)

Wrap each character of upright glyph orientation with span.upright and sideways glyph orientation with span.sideways (see UTR50)., (*3)

Expected CSS;, (*4)

.tcy {
    text-combine-upright: all;
}
.upright {
    text-orientation: upright;
}
.sideways {
    text-orientation: sideways;
}

Install

composer install

Usage

New static method transformText, (*5)

$result = Denshoch\Harusame::transformText('平成20年!?');
// => 平成<span class="tcy">20</span>年<span class="tcy">!?</span>

// With options
$options = ['tcyDigit' => 3];
$result = Denshoch\Harusame::transformText('10円玉と100円玉がある。', $options);
// => <span class="tcy">10</span>円玉と<span class="tcy">100</span>円玉がある。

Previous usage, (*6)

$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 Initial Description
tcyDigit integer 2 Maximum number of digits to add .tcy class. If set to 0, no .tcy class will be added.
autoTextOrientation boolean true Add .upright and .sideways class or not.

Error Handling

When invalid XML is provided as input, the transform method will return the original text instead of throwing an exception. Additionally, an error message will be logged to indicate that invalid XML was encountered. This allows for graceful handling of errors while still providing feedback about the issue., (*7)

Test

``` $ vendor/bin/phpunit, (*8)

The Versions

03/03 2017

dev-master

9999999-dev https://github.com/denshoch/harusame

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

  Sources   Download

MIT

The Requires

 

The Development Requires

03/03 2017

1.0.3

1.0.3.0 https://github.com/denshoch/harusame

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

  Sources   Download

MIT

The Requires

 

The Development Requires

22/11 2016

1.0.2

1.0.2.0 https://github.com/denshoch/harusame

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

  Sources   Download

MIT

The Requires

 

The Development Requires

20/08 2016

1.0.1

1.0.1.0 https://github.com/denshoch/harusame

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

  Sources   Download

MIT

The Requires

 

The Development Requires

19/08 2016

1.0.0

1.0.0.0 http://denshochan.com/

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

  Sources   Download

MIT

The Requires

 

The Development Requires