Skip to content

Instantly share code, notes, and snippets.

@karlhorky
Created August 28, 2020 16:23
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 karlhorky/71dda7dfb9327e98fdb7a01574626b48 to your computer and use it in GitHub Desktop.
Save karlhorky/71dda7dfb9327e98fdb7a01574626b48 to your computer and use it in GitHub Desktop.
Prettify Runkit HTML Output with Prettier
// Prettify Runkit HTML
// (Not relevant for demo)
const html = '<div id="a">asdf</div>';
const prettier = require("prettier");
'<pre>' +
prettier
.format(html, {parser: 'html', htmlWhitespaceSensitivity: 'ignore'})
.replace(/</g, '&lt;') +
'</pre>';
// See demo here: https://runkit.com/embed/mfigg7b3rcb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment