Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add printable design using Paged.js #62

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
23cec7a
feat: add printable version using Paged.js
vihuna Sep 29, 2023
600ad5b
Add basic CSS styles for A4 paper document
vihuna Oct 3, 2023
f3065a1
fix: adjust `sidenote` width to A4-paper margins
vihuna Oct 3, 2023
b373dcc
Add page numbers
vihuna Oct 4, 2023
90f2bd1
fix: restore ToC section numbering
vihuna Oct 6, 2023
a82a79a
Add page numbers to ToC entries
vihuna Oct 13, 2023
973f21e
fix: add CSS paginated stylesheet to loading section
vihuna Nov 1, 2023
a98dd41
refactor: change Paged.js config loading method
vihuna Nov 11, 2023
aa16578
fix: get HTML `body` directly
vihuna Nov 11, 2023
5cd02ce
fix: remove the functions wrapping the promises
vihuna Nov 28, 2023
e2076b0
fix: follow javascript best practices
vihuna Nov 28, 2023
dcb942a
fix: avoid section anchor reload issue
vihuna Nov 28, 2023
52b3b83
Remove image `loading` attribute by default
vihuna Nov 28, 2023
965364d
Merge the two CSS paged layout files
vihuna Nov 29, 2023
75980d9
Format, clean trailing whitespaces, comments, ...
vihuna Dec 11, 2023
99ffad3
fix: wrap preformatted text, avoid scrollbars
vihuna Dec 11, 2023
197e24e
fix: adjust end-of-proof symbol for paged layout
vihuna Dec 11, 2023
7e1d4aa
fix(doc): remove "scroll overflow" section
vihuna Dec 11, 2023
0dfda4a
Do not use CSS `@import`
vihuna Feb 1, 2024
d2d2336
fix: amend #99ffad3, text wrapping for `pre`, `code`
vihuna Feb 1, 2024
b3f8ad2
Allow text wrapping for long url's in link text
vihuna Feb 1, 2024
f136d14
fix: avoid hyphenation because Paged.js issues
vihuna Feb 1, 2024
78ac1ff
fix: remove the de facto disabled option `removeImgLoading`
vihuna Feb 1, 2024
4316b5c
Update default page size and margins
vihuna Feb 1, 2024
36d5e32
feat: add some utility classes
vihuna Feb 1, 2024
d803db3
fix: follow better CSS formatting guidelines
vihuna Feb 1, 2024
6aa3068
Do not convert units from LaTeX-pt to HTML-pt ...
vihuna Feb 1, 2024
705af5b
fix: set default line spacing to one and half
vihuna Feb 1, 2024
2fc21f1
fix: adjust theme colors, remove dark theme
vihuna Feb 5, 2024
21f155e
Use vite to build `latexcss-paged.js` script
vihuna Feb 11, 2024
9b73d07
fix: use `latex.now.sh` domain in code examples
vihuna Feb 11, 2024
8ca86df
fix: remove unnecessary CSS property
vihuna Feb 12, 2024
e41f347
fix: change CSS Page Model image
vihuna Feb 12, 2024
b84f0b9
feat: add CSS Paged Media footnotes
vihuna Feb 17, 2024
316b5c3
fix: transform sidenotes to Paged Media footnotes
vihuna Feb 17, 2024
32f1090
fix(doc): update sidenotes section for paged layout
vihuna Feb 17, 2024
5d6aadb
feat: add utility classes for page break control
vihuna Mar 24, 2024
b1d032b
fix: end inmediately if there is no `footnotes` div
vihuna Mar 24, 2024
218f532
feat: add simple top warning banner
vihuna Apr 7, 2024
cb05ba9
fix: make consistent rendering across different environments
vihuna Apr 7, 2024
c265215
fix: adjust document font sizes for 10pt and 12pt
vihuna Apr 7, 2024
bf7c2e6
fix: avoid end-of-proof sign vertical overflow
vihuna Apr 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Don't accidentally commit the build artifact to the repo
# Don't accidentally commit the build artifacts to the repo
style.min.css
style-paged.min.css
latexcss-paged.js

#region https://github.com/github/gitignore/blob/main/Node.gitignore
# Logs
Expand Down
Binary file added fonts/LMMono-regular.ttf
Binary file not shown.
Binary file added fonts/LMMono-regular.woff
Binary file not shown.
Binary file added fonts/LMMono-regular.woff2
Binary file not shown.
Binary file added fonts/LibertinusMono-regular.woff2
Binary file not shown.
790 changes: 790 additions & 0 deletions index-paged.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions latexcss-js.vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import("vite").UserConfig} */
export default {
build: {
emptyOutDir: false,
lib: {
entry: "./src/index.js",
formats: ["iife"],
fileName: "latexcss-paged",
name: "LatexCss"
},
},
};

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
"fonts",
"lang",
"style.css",
"style.min.css"
"style.min.css",
"style-paged.css",
"style-paged.min.css",
"src",
"latexcss-paged.js"
],
"scripts": {
"prepack": "vite build && cp dist/style.css style.min.css",
"build": "npm pack --dry-run"
"prepack": "npm run build-lib && cp dist/style.css style.min.css && cp dist/style-paged.css style-paged.min.css && cp dist/latexcss-paged.iife.js latexcss-paged.js",
"build": "npm pack --dry-run",
"build-lib": "vite build && vite build --config latexcss-js.vite.config.js",
"preview": "vite preview --outDir ./ --port 8000"
},
"repository": {
"type": "git",
Expand Down
64 changes: 64 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*! LatexCss library to configure Paged.js for LaTeX.css paged layout.
* Adds automatically Prism.js and MathJax startup promises to Paged.js
* configuration, if they are found.
*
* Source: https://github.com/vincentdoerig/latex-css
* Licensed under MIT (https://github.com/vincentdoerig/latex-css/blob/master/LICENSE)
*/

import { startupPromise } from "./startup.js";
import * as utils from "./utils.js";

let LatexCssConfig = window.LatexCssConfig || {
showBrowserWarning: true
};

let PagedConfig = window.PagedConfig;

let LatexCss = {};
LatexCss.startupPromise = startupPromise;
LatexCss.utils = utils;

const afterPaged = function() {
// Go to section anchor after Paged.js has been loaded
utils.fixAnchorReload();
// Add non-Blink browsers warning
if (LatexCssConfig.showBrowserWarning &&
!window.navigator.userAgent.includes("Chrome")) utils.addBrowserWarn();
console.log("LatexCss: Pagedjs script finished");
}

LatexCss.afterPaged = afterPaged;

window.LatexCss = LatexCss;

// Scroll to the top of the document
utils.scrollToTop();

// Paged.js default configuration, if `PagedConfig.before` and `PagedConfig.after`
// have not been customized by the user.
// `PagedConfig` is read by Paged.js when starting; although `before` and `after`
// functions are going to be evaluated after the HTML document has been completely
// read.
if (typeof PagedConfig === "undefined") {
window.PagedConfig = {
before: () => {
return startupPromise();
},
after: () => {
afterPaged();
},
};
} else {
if (typeof PagedConfig.before === "undefined") {
window.PagedConfig.before = function() {
return startupPromise();
};
}
if (typeof PagedConfig.after === "undefined") {
window.PagedConfig.after = function() {
afterPaged();
};
}
}

Loading