-
-
Save maticrivo/5894478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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.]+)(px)/g, function(m){ | |
var measure = parseFloat(m.split("px")[0]); | |
var newMeasure = measure / 10; | |
newMeasure = newMeasure.toFixed(2); | |
newMeasure = newMeasure.replace(/(\.[0-9]*?)0+$/, "$1"); // remove trailing zeros | |
newMeasure = newMeasure.replace(/\.$/, ""); // remove trailing dot | |
return newMeasure+"rem"; | |
}); | |
file.parentNode.innerHTML = "<pre>"+newContent+"</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment