Commit e914af20 authored by Fred Chasen's avatar Fred Chasen

Merge branch 'footnotes' into 'master'

Add footnotes module

See merge request tools/pagedjs!119
parents dd209156 3848c2e8
Pipeline #731 passed with stage
in 4 minutes and 30 seconds
FROM node:12-stretch
FROM node:15-stretch
# Application parameters and variables
ENV NODE_ENV=development
......
......@@ -138,6 +138,7 @@ layoutNode(node)
renderNode(node, sourceNode, layout)
onOverflow(overflow, rendered, bounds)
onBreakToken(breakToken, overflow, rendered)
afterOverflowRemoved(removed, rendered)
```
## Setup
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ import json from 'rollup-plugin-json';
// import builtins from 'rollup-plugin-node-builtins';
// import globals from 'rollup-plugin-node-globals';
import pkg from './package.json';
// import pkg from './package.json';
import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
......
This diff is collapsed.
const TIMEOUT = 10000;
describe("footnote-display", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnote-display/footnote-display.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 6 pages", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(6);
});
if (!DEBUG) {
it("should create a pdf", async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(2);
expect(pdf).toMatchPDFSnapshot(3);
expect(pdf).toMatchPDFSnapshot(4);
});
}
}
);
This diff is collapsed.
const TIMEOUT = 10000;
describe("footnote-policy", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnote-policy/footnote-policy.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 6 pages", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(6);
});
it("display auto footnotes should split text", async () => {
let textStart = await page.$eval("[data-page-number='1']", (r) => r.textContent);
expect(textStart).toContain("Characteres");
let textEnd = await page.$eval("[data-page-number='2']", (r) => r.textContent);
expect(textEnd).toContain("genus typos me vidisse");
});
it("display line footnotes should stay with the callout line", async () => {
let textStart = await page.$eval("[data-page-number='4']", (r) => r.textContent);
// line
expect(textStart).toContain("Strasburg");
// footnote
expect(textStart).toContain("Argentoratensi");
});
it("display block footnotes should stay with the callout paragraph block", async () => {
let textStart = await page.$eval("[data-page-number='6']", (r) => r.textContent);
// paragraph
expect(textStart).toContain("The legend");
// footnote
expect(textStart).toContain("Argentoratensi");
});
if (!DEBUG) {
it("should create a pdf", async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(2);
expect(pdf).toMatchPDFSnapshot(3);
expect(pdf).toMatchPDFSnapshot(4);
expect(pdf).toMatchPDFSnapshot(6);
});
}
}
);
const TIMEOUT = 10000;
describe("footnotes-counter-reset-page", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnotes-counter-reset-page/footnotes-counter-reset-page.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 6 pages", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(6);
});
if (!DEBUG) {
it("should create a pdf", async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(1);
expect(pdf).toMatchPDFSnapshot(2);
expect(pdf).toMatchPDFSnapshot(6);
});
}
}
);
const TIMEOUT = 10000;
describe("footnotes-counter-reset", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnotes-counter-reset/footnotes-counter-reset.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 5 pages", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(5);
});
if (!DEBUG) {
it("should create a pdf", async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(2);
expect(pdf).toMatchPDFSnapshot(4);
expect(pdf).toMatchPDFSnapshot(5);
});
}
}
);
<!DOCTYPE html PUBLIC>
<html lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>
Footnotes
</title>
<!-- Paged js-->
<script src="../../../dist/paged.polyfill.js"></script>
<style>
body {
widows: 1;
orphans: 1;
}
@media screen {
.pagedjs_page {
box-shadow: 0 0 0 1px #666;
}
.pagedjs_area {
box-shadow: 0 0 0 1px teal;
}
}
.footnote,
.footnote-ref::after {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
line-height: 14px;
margin-top: 16px;
}
@page {
size: 160mm 210mm;
margin-top: 83px;
margin-bottom: 86px;
margin-left: 35mm;
margin-right: 35mm;
@bottom-center {
content: counter(page);
}
@footnote {
background-color: #cfcfcf;
border-top: 2px dotted black;
}
}
p {
font-family: Georgia, 'Times New Roman', Times, serif;
margin-top: 0;
margin-bottom: 0;
text-align: justify;
font-size: 14px;
line-height: 16px;
}
.afnanch {
display: none;
}
hr {
border: none;
}
.pfirst {
padding-top: 50mm;
}
.footnote {
color: red;
float: footnote;
}
::footnote-marker {
color: blue !important;
font-weight: bold;
font-size: 30px;
content: "hello";
}
::footnote-call {
color: orange;
font-weight: bold;
font-size: 30px !important;
content: "hello";
}
</style>
</head>
<body>
<p>No one has done more to clear the way for a free
investigation of all questions relating to the origin
of printing than Dr. Van der Linde, in his able essay,
<em>The Haarlem Legend</em>,
<span class="footnote" data-note="01" id="note-01"><em>The Haarlem Legend of the Invention of Printing by
Lourens Janszoon Coster, critically examined.</em> From the Dutch by J.
H. Hessels, with an introduction and classified list of the Costerian
Incunabula. London, 1871. 8vo.</span> which, while disposing ruthlessly of
the fiction of Coster’s invention, lays down the important
principle, too often neglected by writers on the subject,
that the essence of Typography consists in the mobility of
the types, and that, therefore, it is not a development of
the long practised art of printing from fixed blocks, but
an entirely distinct invention.</p>
<p>The principle is so important, and Dr. Van der Linde’s words are so
emphatic, that we make no apology for quoting them:―</p>
</section>
</body>
</html>
\ No newline at end of file
const TIMEOUT = 10000;
describe("footnotes counter content", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnotes-counter/footnotes-counter.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 1 page", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(1);
});
if (!DEBUG) {
it("should create a pdf", async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(1);
});
}
}
);
This diff is collapsed.
const TIMEOUT = 10000;
describe("footnotes lastpage", () => {
let page;
beforeAll(async () => {
page = await loadPage("notes/footnotes-lastpage/footnotes-lastpage.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should render 6 pages", async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => {
return r.length;
});
expect(pages).toEqual(6);
});
it("not display footnote 4 on page 2", async () => {
let textStart = await page.$eval("[data-page-number='2']", (r) => r.textContent);
// line
expect(textStart).toContain("sand-cast bodies");
// footnote
expect(textStart).not.toContain("three-line pica");
});
it("should display footnote 4 on page 3", async () => {
let textStart = await page.$eval("[data-page-number='3']", (r) => r.textContent);
// line
expect(textStart).not.toContain("sand-cast bodies");
// footnote
expect(textStart).toContain("three-line pica");
});
it("not display footnote 8 on page 5", async () => {