| 1 |
[](https://packagist.org/packages/cssjanus/cssjanus) |
| 2 |
|
| 3 |
# CSSJanus |
| 4 |
|
| 5 |
Convert CSS stylesheets between left-to-right and right-to-left. |
| 6 |
|
| 7 |
## Usage |
| 8 |
|
| 9 |
```php |
| 10 |
transform( string $css, bool $swapLtrInURL = false, bool $swapLeftInURL = false ) : string |
| 11 |
``` |
| 12 |
|
| 13 |
Parameters; |
| 14 |
|
| 15 |
* ``$css`` (string) Stylesheet to transform. |
| 16 |
* ``$swapLtrInURL`` (boolean) Swap `ltr` to `rtl` direction in URLs. |
| 17 |
* ``$swapLeftInURL`` (boolean) Swap `left` and `right` edges in URLs. |
| 18 |
|
| 19 |
Example: |
| 20 |
|
| 21 |
```php |
| 22 |
$rtlCss = CSSJanus::transform( $ltrCss ); |
| 23 |
``` |
| 24 |
|
| 25 |
### Preventing flipping |
| 26 |
|
| 27 |
If a rule is not meant to be flipped by CSSJanus, use a `/* @noflip */` comment to protect the rule. |
| 28 |
|
| 29 |
```css |
| 30 |
.rule1 { |
| 31 |
/* Will be converted to margin-right */ |
| 32 |
margin-left: 1em; |
| 33 |
} |
| 34 |
/* @noflip */ |
| 35 |
.rule2 { |
| 36 |
/* Will be preserved as margin-left */ |
| 37 |
margin-left: 1em; |
| 38 |
} |
| 39 |
``` |
| 40 |
|
| 41 |
## Port |
| 42 |
|
| 43 |
This is a PHP port of the Node.js implementation of CSSJanus. Feature requests and bugs related |
| 44 |
to the actual CSS transformation logic or test cases of it, should be submitted upstream |
| 45 |
at <https://github.com/cssjanus/cssjanus>. |
| 46 |
|
| 47 |
CSSJanus was originally a [Google project](http://code.google.com/p/cssjanus/). |
| 48 |
|
| 49 |
## Contribute |
| 50 |
|
| 51 |
* Issue tracker: <https://phabricator.wikimedia.org/tag/cssjanus/> |
| 52 |
* Source code: <https://gerrit.wikimedia.org/g/mediawiki/libs/php-cssjanus> |
| 53 |
* Submit patches via Gerrit: <https://www.mediawiki.org/wiki/Developer_account> |