Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
feat(Pages extension): Add the pages extension
Browse files Browse the repository at this point in the history
Closes #23.
  • Loading branch information
nokome committed Feb 21, 2020
1 parent 5abced5 commit eb64e1a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/extensions/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export const extensions: {
'cite-mla': Promise<unknown>
code: Promise<unknown>
math: Promise<unknown>
pages: Promise<unknown>
person: Promise<unknown>
} = {
cite: import('./cite'),
'cite-apa': import('./cite-apa'),
'cite-mla': import('./cite-mla'),
code: import('./code'),
math: import('./math'),
pages: import('./pages'),
person: import('./person')
}
18 changes: 18 additions & 0 deletions src/extensions/pages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Pages extension

Provides a [`@media print` CSS at-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/@page) to modify properties when printing a document e.g. to PDF.

## Notes

- This is an initial, basic, implementation.

- In the future, we may use https://www.pagedmedia.org/paged-js/ for better support for the `@page` rule.

- That might allow theme authors to specify additonal things to go in printed pages e.g. headers and footers, for their theme.


## Resources

- https://www.smashingmagazine.com/2018/05/print-stylesheets-in-2018/

- https://www.pagedmedia.org/paged-js/
3 changes: 3 additions & 0 deletions src/extensions/pages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Do any initialization that your extension requires here.

export {}
21 changes: 21 additions & 0 deletions src/extensions/pages/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@media print {
/* Document nodes to avoid a break after */
:--Heading {
page-break-after: avoid;
}

/* Document nodes to avoid a break inside */
:--Figure,
:--Table,
:--Datatable,
:--MathBlock,
:--CodeBlock,
:--CodeChunk {
page-break-inside: avoid;
}

/* Elements not to display */
stencila-action-menu {
display: none;
}
}
3 changes: 2 additions & 1 deletion src/themes/skeleton/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../../extensions/cite-apa'
import '../../extensions/code'
import '../../extensions/math'
import '../../extensions/pages'
import '../../extensions/person'
import '../../extensions/cite-apa'
1 change: 1 addition & 0 deletions src/themes/skeleton/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@import '../../extensions/cite-apa/styles.css';
@import '../../extensions/code/styles.css';
@import '../../extensions/math/styles.css';
@import '../../extensions/pages/styles.css';
@import '../../extensions/person/styles.css';

:--ArrayValidator {
Expand Down

0 comments on commit eb64e1a

Please sign in to comment.