cssjanus / cssjanus
Convert CSS stylesheets between left-to-right and right-to-left.
Installs: 930 724
Dependents: 4
Suggesters: 0
Security: 0
Stars: 17
Watchers: 8
Forks: 17
Open Issues: 0
Requires
- php: >=7.2.0
Requires (Dev)
- mediawiki/mediawiki-phan-config: 0.10.6
- php-parallel-lint/php-parallel-lint: ^1.3.0
- phpunit/phpunit: ^8.5.15
- squizlabs/php_codesniffer: ^3.6.0
README
CSSJanus
Convert CSS stylesheets between left-to-right and right-to-left.
Usage
transform( string $css, bool $swapLtrInURL = false, bool $swapLeftInURL = false ) : string
Parameters;
$css
(string) Stylesheet to transform.$swapLtrInURL
(boolean) Swapltr
tortl
direction in URLs.$swapLeftInURL
(boolean) Swapleft
andright
edges in URLs.
Example:
$rtlCss = CSSJanus::transform( $ltrCss );
Preventing flipping
If a rule is not meant to be flipped by CSSJanus, use a /* @noflip */
comment to protect the rule.
.rule1 { /* Will be converted to margin-right */ margin-left: 1em; } /* @noflip */ .rule2 { /* Will be preserved as margin-left */ margin-left: 1em; }
Who uses CSSJanus?
- Wikimedia Foundation, the non-profit behind Wikipedia and other free knowledge projects.
Used in MediaWiki, on Wikipedia, and other projects.
Port
This is a PHP port of the Node.js implementation of CSSJanus, and was originally based on a Google project.
Feature requests and bugs related to the actual CSS transformation logic or test cases of it, should be submitted upstream at https://github.com/cssjanus/cssjanus.
Upstream releases will be ported here.