Flip CSS stylesheets between left-to-right and right-to-left. From Wikimedia.
JavaScript HTML CSS
Latest commit 5cd5f57 Feb 12, 2018
Krinkle and jdforrester build: Bump devDependencies (grunt) (#55)
* grunt 1.0.1 → 1.0.2
  - Removes grunt's dependency on the deprecated 'coffee-script' package,
    by using 'coffeescript' instead.
    This fixes a warning shown during 'npm install' when developing cssjanus
    locally.

README.md

Build Status npm

CSSJanus

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

Based the original CSSJanus Google project.

Install

npm install cssjanus

Basic usage

var cssjanus = require( 'cssjanus' );
var rtlCss = cssjanus.transform( ltrCss );

Advanced usage

transform( css, swapLtrRtlInUrl, swapLeftRightInUrl )
  • css (String) Stylesheet to transform
  • swapLtrRtlInUrl (Boolean) Swap 'ltr' and 'rtl' in URLs
  • swapLeftRightInUrl (Boolean) Swap 'left' and 'right' in URLs

Preventing flipping

Use a /* @noflip */ comment to protect a rule from being changed.

.rule1 {
  /* Will be converted to margin-right */
  margin-left: 1em;
}
/* @noflip */
.rule2 {
  /* Will be preserved as margin-left */
  margin-left: 1em;
}

See also