cssjanus/cssjanus

Convert CSS stylesheets between left-to-right and right-to-left.

v2.0.0 2021-05-10 17:03 UTC

This package is auto-updated.

Last update: 2021-07-31 00:07:58 UTC


README

Build Status Packagist Coverage Status

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) Swap ltr to rtl direction in URLs.
  • $swapLeftInURL (boolean) Swap left and right 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?

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.