Skip to content

Instantly share code, notes, and snippets.

View rnowm's full-sized avatar

Arnau March Castillo rnowm

  • Sitges, Barcelona
View GitHub Profile
@rnowm
rnowm / CSS units parser
Created November 5, 2012 07:54 — forked from basiclines/CSS units parser
JS for parsing CSS numeric values followed by 'rem' unit and perform math operations over it
//Open the file directly in the browser and run this script from the console
//Assumptions: The browser uses a <pre/> tag for showing the CSS code
var file = document.querySelector("pre");
var fileContent = file.innerHTML;
var newContent = fileContent.replace(/([\d.]+)(rem)/g, function(m){
var measure = parseFloat(m.split("rem")[0]);
var newMeasure = measure / 1.6;