Skip to content
Flip CSS stylesheets between left-to-right and right-to-left. From Wikimedia.
JavaScript HTML CSS
Branch: master
Clone or download
Krinkle and jdforrester Add benchmark (#63)
* build: Update dev dependencies

eslint-config-wikimedia   0.3.0  →   0.5.0
grunt                     1.0.2  →   1.0.4
grunt-contrib-watch       1.0.0  →   1.1.0
grunt-eslint             18.0.0  →  21.0.0
grunt-jsonlint            1.0.8  →   1.1.0

grunt-eslint has a newer version (21.0) that requires Node 6,
given we still support Node 4, staying on the latest before it.

* test: Add benchmarks

Uses the same fixtures as the benchmarks for php-cssjanus.
Latest commit b05caf9 May 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build/tasks build: Add npm-run command for 'grunt site' (#66) Jul 3, 2018
site site: Remove now-redundant fake require() in index.html (#67) Jul 5, 2018
src Document known backtracking issue May 10, 2019
test
.eslintrc.json
.gitignore Add benchmark (#63) May 10, 2019
.npmignore build: Add .npmignore file Oct 13, 2014
.travis.yml Add benchmark (#63) May 10, 2019
Gruntfile.js
History.md
LICENSE.txt Drop support for node.js 0.4 and 0.6 Jul 4, 2014
README.md readme: Update Travis badge to dot-com (#59) May 18, 2018
package.json Add benchmark (#63) May 10, 2019

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

You can’t perform that action at this time.