<!DOCTYPE html><html lang="en">  <head>    <base href="/post-processing/" />    <meta charset="utf-8" />    <meta      name="description"      content="Rewrite the finished HTML in a response handler: move inline styles into the head with Cheerio and format the result with Prettier."    />    <meta name="viewport" content="width=device-width, initial-scale=1" />    <meta name="color-scheme" content="dark" />    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />    <link rel="stylesheet" href="/index.css?v=mwyxso0s" />    <link rel="stylesheet" href="/post-processing/index.css?v=mwyxso0s" />    <link rel="canonical" href="https://expo.jeasx.dev/post-processing" />    <script type="module" src="/index.js?v=mwyxso0s"></script>    <title>      Post-process HTML with Prettier and Cheerio » Jeasx - JSX with Ease    </title>    <style>      .c0 {        --heading: orange;      }      .c1 {        text-align: center;      }      .c2 {        color: orange;      }      .c3 {        color: var(--muted);      }    </style>  </head>  <body>    <header class="shell-header">      <nav class="container">        <ul>          <li>            <a href="/" class="shell-brand"              ><span class="shell-gradient">Jeasx</span> Expo</a            >          </li>          <li><a href="/" class="shell-back">← All examples</a></li>        </ul>        <ul>          <li>            <a              href="https://github.com/jeasx/jeasx-expo/tree/main/src/post-processing"              class="shell-source"              title="View source code"              ><img                src="/github-GDUVNX2O.svg"                width="20"                height="20"                alt=""              /><span>Source</span></a            >          </li>        </ul>      </nav>    </header>    <main class="container">      <section class="pp-hero c0 c1">        <h1>Post-process HTML with Prettier and Cheerio</h1>        <p class="lead">          Jeasx lets you rewrite the finished HTML with a          <a href="https://www.jeasx.dev/faq#response-handler"            >response handler</a          >. It is set on <code>this.responseHandler</code>, receives the          rendered payload and returns the new text. This page rewrites its very          own markup.        </p>      </section>      <h2>Extract inline styles with Cheerio</h2>      <p>        <a href="https://cheerio.js.org">Cheerio</a> turns all inline styles        into CSS classes in the head of the page.      </p>      <ol class="pp-steps">        <li>          <strong class="c2">Render</strong          ><span>JSX produces HTML full of inline style attributes.</span>        </li>        <li>          <strong class="c2">Collect</strong          ><span            >Cheerio finds each declaration; identical ones share a single            class.</span          >        </li>        <li>          <strong class="c2">Rewrite</strong          ><span            >Classes go into one style tag in the head and Prettier formats the            result.</span          >        </li>      </ol>      <p class="c1 c3">        Compare the original and the rewritten markup of this very page below.      </p>      <div class="compare">        <figure class="compare-item">          <figcaption>            <i></i><i></i><i></i>Original source<em>before</em>          </figcaption>          <iframe            title="Original source"            src="?view=code&amp;source=raw"          ></iframe>        </figure>        <figure class="compare-item">          <figcaption>            <i></i><i></i><i></i>Rewritten markup<em>after</em>          </figcaption>          <iframe title="Rewritten markup" src="?view=code"></iframe>        </figure>      </div>    </main>    <footer class="container shell-footer">      <p>        <a href="https://www.jeasx.dev">jeasx.dev</a        ><span aria-hidden="true">·</span        ><a href="https://github.com/jeasx/jeasx-expo">GitHub</a>      </p>      <p>© 2026 · powered by Jeasx on Node@26.13.1</p>    </footer>  </body></html>