Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FontAwesome R2 plugin prototype

  • Loading branch information...
commit e3918ac10a507cbdd37f0b04c16d599d31c0c10f 1 parent 55c4f9e
@jbalsas jbalsas authored
Showing with 43 additions and 1 deletion.
  1. +37 −0 plugins/fontawesome.js
  2. +6 −1 r2.js
View
37 plugins/fontawesome.js
@@ -0,0 +1,37 @@
+var swapIcons = {
+ 'f060': 'f061',
+ 'f061': 'f060',
+ 'f0a4': 'f0a5',
+ 'f0a5': 'f0a4',
+ 'f0d9': 'f0da',
+ 'f0da': 'f0d9',
+ 'f100': 'f101',
+ 'f101': 'f100',
+ 'f104': 'f105',
+ 'f105': 'f104',
+ 'f137': 'f138',
+ 'f138': 'f137',
+ 'f053': 'f054',
+ 'f054': 'f053',
+ 'f0a8': 'f0a9',
+ 'f0a9': 'f0a8',
+ 'f177': 'f178',
+ 'f178': 'f177'
+ },
+ contentRegexp = /^"\\(.*)"$/,
+
+ plug = function(r2) {
+ r2.valueMap['content'] = function(v) {
+ if (contentRegexp.test(v)) {
+ icon = contentRegexp.exec(v)[1];
+
+ if (swapIcons[icon]) {
+ v = '"\\' + swapIcons[icon] + '"';
+ }
+ }
+
+ return v;
+ }
+ };
+
+module.exports.plug = plug;
View
7 r2.js
@@ -7,7 +7,8 @@
var fs = require('fs')
, parser = require('css-parse')
- , builder = require('css-stringify');
+ , builder = require('css-stringify')
+ , fa = require('./plugins/fontawesome');
function quad(v, m) {
// 1px 2px 3px 4px => 1px 4px 3px 2px
@@ -210,3 +211,7 @@ module.exports.exec = function (args) {
module.exports.swap = function (css, options) {
return r2(css, options)
}
+
+module.exports.valueMap = valueMap;
+
+fa.plug(module.exports);
Please sign in to comment.
Something went wrong with that request. Please try again.