Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Last active December 3, 2015 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/59b5272522b09d2d9a40 to your computer and use it in GitHub Desktop.
Save Noitidart/59b5272522b09d2d9a40 to your computer and use it in GitHub Desktop.
_ff-addon-snippet-prettifyCssHtmlJs - Shows how to prettify CSS/JS/HTML using the built-in stuff in Firefox.
var { devtools } = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {});
devtools.lazyRequireGetter(this, "beautify", "devtools/jsbeautify");
beautify.css('td{color:red}');
beautify.js('{a:{b:true}}'); // docs on the options, which are passed as second argument: https://dxr.mozilla.org/mozilla-central/source/devtools/shared/jsbeautify/src/beautify-js.js#46
beautify.html('<html><head></head><body><div>rawr</div></body></html>');
@Noitidart
Copy link
Author

README

Rev1

  • Tested in Firefox 43. But taken from MXR of Firefox 42 so it should work there as well
  • Per DXR it looks like the path to Loader.jsm changes to resource://devtools/shared/Loader.jsm

Rev2

  • Updated so it shows how to load it lazy, and gives access to the css, js, and html beautifiers

Rev3

  • Updated description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment