Commit dcf4ca9b authored by Fred Chasen's avatar Fred Chasen
Browse files

Add inline styles for polyfill, update readme, default test example

parent 4e42696f
......@@ -62,4 +62,26 @@ $ npm run prepare
## Testing
`brew install ghostscript`
To test the pdf output, you'll need to install ghostscript locally.
brew install ghostscript
Then run the jest tests in puppeteer.
npm test
To debug the results of a test in a browser you can add `NODE_ENV=debug`
NODE_ENV=debug npm test
To update the stored pdf images you can run
npm test -- -u
......@@ -48,7 +48,14 @@ ready.then(async function () {
return sheet.href;
// TODO: add inline styles
// Get inline styles
let inlineStyles = Array.from(document.querySelectorAll("style"));
inlineStyles.forEach((inlineStyle) => {
let obj = {};
obj[window.location.href] = inlineStyle.textContent;
// Process styles
let styles = new Polisher();
......@@ -11,11 +11,25 @@
<script src="../../../dist/paged.polyfill.js"></script>
@page {
size: 'letter';
margin: 1.2in;
border: 1px solid black;
<section class="body-rw Chapter-rw" epub:type="bodymatter chapter">
<h1><span class="audio" id="c001s0000">Chapter 2. Loomings.</span></h1></header>
<section id="cover">
<h1>Auroræ : their characters and spectra</h1>
<p><span class="audio" id="c001s0001">Call me Ishmael.</span> <span class="audio" id="c001s0002">Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.</span> <span class="audio" id="c001s0003">It is a way I have of driving off the spleen and regulating the circulation.</span> <span class="audio" id="c001s0004">Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can.</span> <span class="audio" id="c001s0005">This is my substitute for pistol and ball.</span> <span class="audio" id="c001s0006">With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship.</span> <span class="audio" id="c001s0007">There is nothing surprising in this.</span> <span class="audio" id="c001s0008">If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.</span></p>
<p><span class="audio" id="c001p0002">There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs—commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</span></p>
<p><span class="audio" id="c001p0003">Circumambulate the city of a dreamy Sabbath afternoon. Go from Corlears Hook to Coenties Slip, and from thence, by Whitehall, northward. What do you see?—Posted like silent sentinels all around the town, stand thousands upon thousands of mortal men fixed in ocean reveries. Some leaning against the spiles; some seated upon the pier-heads; some looking over the bulwarks of ships from China; some high aloft in the rigging, as if striving to get a still better seaward peep. But these are all landsmen; of week days pent up in lath and plaster—tied to counters, nailed to benches, clinched to desks. How then is this? Are the green fields gone? What do they here?</span></p>
<p><span class="audio" id="c001p0004">But look! here come more crowds, pacing straight for the water, and seemingly bound for a dive. Strange! Nothing will content them but the extremest limit of the land; loitering under the shady lee of yonder warehouses will not suffice. No. They must get just as nigh the water as they possibly can without falling in. And there they stand—miles of them—leagues. Inlanders all, they come from lanes and alleys, streets and avenues—north, east, south, and west. Yet here they all unite. Tell me, does the magnetic virtue of the needles of the compasses of all those ships attract them thither?</span></p>
......@@ -38,7 +38,7 @@ describe('break', async () => {
it('should render text', async () => {
let text = await page.evaluate(() => document.body.textContent);
expect(text).toContain('Chapter 1. Loomings.');
it('should render 1 page', async () => {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment