volumetric-regimes-book/command-line/templates/template.html

77 lines
2.7 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2021-11-26 18:59:40 +01:00
<html lang="en-us">
<head>
<meta charset="utf-8">
<link href="./css/pagedjs.css" rel="stylesheet" type="text/css">
<link href="./css/print.css" rel="stylesheet" type="text/css" media="print">
2021-11-10 23:14:54 +01:00
<!-- <link href="./css/baseline.css" rel="stylesheet" type="text/css" media="print"> -->
2021-11-26 18:59:40 +01:00
<script>
2021-12-03 00:01:13 +01:00
// Thank you paged.js team for the Hyphenopoly tip!
2021-11-26 18:59:40 +01:00
// config for hyphenopoly
var Hyphenopoly = {
require: {
"en-us": "FORCEHYPHENOPOLY"
},
paths: {
patterndir: "./js/hyphens/patterns/",
maindir: "./js/hyphens/"
},
setup: {
dontHyphenateClass: "noHyphen",
safeCopy: false,
hide: "nothing",
selectors: {
"p": {
hyphen: "\u00AD",
// hyphen: "•",
compound: "all",
minWordLength: 5,
leftmin: 3,
rightmin: 0,
orphanControl: 1
}
}
}
}
</script>
<script src="./js/hyphens/Hyphenopoly_Loader.js"></script>
<!-- <script src="./js/paged.js" type="text/javascript"></script> -->
<script src="./js/paged.polyfill.js"></script>
<script src="./js/runHyphens.js"></script>
</head>
<body>
2021-12-03 00:01:13 +01:00
<div id="wrapper">
{{ publication_unfolded }}
</div>
<script>
// With many thanks to Julien Taquet for digging into Paged.js
// to find a way to remove hyphenated words on page breaks!!
class noHyphenBetweenPage extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
this.hyphenToken;
}
afterPageLayout(pageFragment, page, breakToken) {
if (pageFragment.querySelector('.pagedjs_hyphen')) {
// find the hyphenated word
let block = pageFragment.querySelector('.pagedjs_hyphen');
block.dataset.ref = this.prevHyphen;
// move the breakToken
let offsetMove = getFinalWord(block.innerHTML).length;
// move the token accordingly
page.breakToken = page.endToken.offset - offsetMove;
// remove the last word
block.innerHTML = block.innerHTML.replace(getFinalWord(block.innerHTML), "");
breakToken.offset = page.endToken.offset - offsetMove;
}
}
}
Paged.registerHandlers(noHyphenBetweenPage);
2021-11-08 22:01:36 +01:00
2021-12-03 00:01:13 +01:00
function getFinalWord(words) {
var n = words.split(" ");
return n[n.length - 1];
}
</script>
</body>
</html>