inverter v0.1.1
Inverter
Simply translate LTR-based CSS file to RTL, or the opposite. Can be both used on the server-side with Node.js, or client-side.
Basic Usage
var inverter = require('inverter');
, inverted_css = inverter.invert('.some_css_class { margin: 8px 3px 9px 2px; float: left; }')You may optionally want to prevent some filters from running:
var inverter = require('inverter');
, inverted_css = inverter.invert(myCSS, {exclude: ['fixGradient']))Inverter will
fixLeftRight: Replace
leftwithrightand the opposite, but:- No replacement will be made between parentheses (
background-image: url(bright-left.png)will be left intact) - No replacement will be made in selectors (
.block-left { […] }will be left intact)
- No replacement will be made between parentheses (
fixBodyDirection: Replace
direction: ltrwithdirection: rtland the opposite, only for the body tagfixCursor: Replace, for example,
cursor: nw-resizewithcursor: ne-resizefixBorderRadius: Fix
border-radiusdefinitions, soborder-radius: 5px 2px 4px / 9px 2pxwill becomeborder-radius: 2px 5px 2px 4px / 2px 9pxfixFourPartNotation: Fixes four part notation, so, for example,
border: 1px 2px 3px 4pxwill be rewritten toborder: 1px 4px 3px 2px. As it can interfere with fixBorderRadius,border-radiusis explicitely excluded from the scope of this fixfixGradient: Fixes most common CSS gradient definitions. This fix will replace
leftwithright,XXXdegwith-XXXdegand the opposites inside gradients.
Tests
This package is tested using Mocha. To run the tests, run npm install inside the package directory to install development dependencies, and then simply make test.