NAME
CSS::Yamaantaka - Converts direction of Cascading Style Sheet (CSS)
SYNOPSIS
use CSS::Yamaantaka;
$ya = CSS::Yamaantaka->new('lr_tb' => 'tb_rl');
$css_source_vertical_rl = $ya->transform($css_source);
DESCRIPTION
As Yamāntaka has many legs, texts can run in various directions: left to right and right to left horizontally; vertically with lines extending right to left and left to right.
CSS::Yamaantaka replaces things directed to "left" or "horizontal-tb" in a Cascading Style Sheet (CSS) file such as float, padding, margin with values directed to "right" or "vertical-rl", and so on.
Transforming directions
Four directions of documents are supported:
- lr-tb
-
The direction specified by
{ direction: ltr; writing-mode: horizontal-tb; }
. For example, most Western writing systems employ it. - rl-tb
-
The direction specified by
{ direction: rtl; writing-mode: horizontal-tb; }
. For example, some Middle Eastern writing systems employ it. - tb-lr
-
The direction specified by
{ writing-mode: vertical-lr; }
. For example, several North Asian writing systems employ it. - lr-tb
-
The direction specified by
{ writing-mode: vertical-rl; }
. East Asian writing systems with vertical layout employ it.
This module chooses transformation by source & resulting directions:
+-----------+-------------+-------------+-------------+--------------+
| from \ to | lr-tb : rl-tb : tb-lr : tb-rl |
+-----------+-------------+-------------+-------------+--------------+
| lr-tb | - : MirrorH : MirrorTL_BR : RotateR |
| rl-tb | MirrorH : - : RotateL* : MirrorTR_BL* |
| tb-lr | MirrorTL_BR : RotateR : - : MirrorV |
| tb-rl | RotateL : MirrorTR_BL : MirrorV : - |
+-----------+-------------+-------------+-------------+--------------+
* Assumed text-orientation: sideways-left.
Each transformation changes line-relative box directions ("right" / "left" of text-align, float and clear, and "top" / "bottom" of vertical-align), physical box directions ("top" / "right" / "bottom" / "left"), global directions specified by body element ("ltr" / "rtl") and direction swapping (horizontal / vertical) as below:
+-------------+-----------+--------------------------+--------+------+
| | line-rel. | box directions : g. dir : h/v |
+-------------+-----------+--------------------------+--------+------+
| MirrorH | revert h. : revert horizontally : revert : - |
| MirrorV | - : revert horizontally : revert : - |
| RotateR | - : rotate clockwise : revert : swap |
| RotateL | - : rotate counter-clockwise : revert : swap |
| MirrorTL_BR | - : revert with tl-br axis : - : swap |
| MirrorTR_BL | - : revert with tr-bl axis : - : swap |
+-------------+-----------+--------------------------+--------+------+
Currently, this module won't fix line-relative text directions ("rtl" / "ltr").
Constructor
- new ( SRC => DEST, [ options... ] )
-
Creates new CSS::Yamaantaka object.
SRC and DEST are the original and resulting directions. Available directions are
'lr_tb'
,'rl_tb'
,'tb_lr'
and'tb_rl'
. Their synonyms are'ltr'
,'rtl'
,'vertical-lr'
and'vertical-rl'
, respectively.Following options are available.
- flip_url => 0|1
-
Fixes "top"/"right"/"bottom"/"left" string within URLs. Default is
0
, won't fix. - swap_ltr_rtl_in_url => 0|1
-
Fixes "ltr"/"rtl" string within URLs, if needed. Default is
0
, won't fix. - ignore_bad_bgp => 0|1
-
Ignores unmirrorable background-position values. Default is
0
, won't ignore and will croak it. - flip_cursor => 0|1
-
Fixes positions "n"/"e"/"s"/"w" and so on within cursor properties. Default is
1
, will fix.
Methods
- body_direction
-
Get direction property or dir attribute of body element thought to be appropriate. Returns
'ltr'
,'rtl'
or undef (unknown).
- text_orientation
-
Get text-orientation property of texts assumed. Returns
'sideways-left'
or undef (upright or sideways-right is assumed).
- transform ( $lines, [ options... ] )
-
Runs the fixing functions against CSS source.
$lines is a string. Following options are available.
- swap_ltr_rtl_in_url => 0|1
-
Overrides this flag if param is set.
- flip_url => 0|1
-
Overrides this flag if param is set.
- flip_cursor => 0|1
-
Overrides this flag if param is set.
Returns same lines directions are changed.
- writing_mode
-
Get writing-mode property of texts thought to be appropriate. Returns
'horizontal-tb'
,'vertical-lr'
,'vertical-rl'
or undef (unknown).
VERSION
Consult $VERSION
variable.
SEE ALSO
Extended CSSJanus supporting vertical-rl writing-mode: http://www.epubcafe.jp/download
AUTHOR
Hatuka*nezumi - IKEDA Soji <hatuka(at)nezumi.nu>.
COPYRIGHT
Copyright (C) 2013 Hatuka*nezumi - IKEDA Soji.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.