Skip to content

Commit

Permalink
improve pagination while printing
Browse files Browse the repository at this point in the history
Avoid widows and orphans, page breaks after headlines (fixes upstream iainc#33)
  • Loading branch information
tbussmann committed Apr 21, 2020
1 parent 59c9577 commit b6538b1
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion GitHub.iatemplate/Contents/Resources/github.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,50 @@ html {
@media print {
.markdown-body {
--horizontal-padding: 75px;
widows: 2; /* avoid single lines at... */
orphans: 2; /* ...begin and end of page */
}
.markdown-body pre code {
white-space: pre-wrap;
}
}

/* avoid page breaks after headlines */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
/* this should be simple but due to WebKit bug https://bugs.webkit.org/show_bug.cgi?id=5097 it isn't:
page-break-after: avoid; /* old syntax, not working in webkit
break-after: avoid-page; /* new syntax, not implemented in webkit
instead, increase the calculated height of headlines by using an invisible element and forbid breaks within: */
page-break-inside: avoid;
}
.markdown-body h1::after,
.markdown-body h2::after,
.markdown-body h3::after,
.markdown-body h4::after,
.markdown-body h5::after,
.markdown-body h6::after {
content: "";
display: block;
height: 50px;
margin-bottom: -50px;
}
/* github-markdown.css does define bottom padding and border for h1 / h2 which conflicts with this hack
remove these and define them top of the workaround instead */
.markdown-body h1,
.markdown-body h2 {
padding-bottom: unset;
border-bottom: unset;
}
.markdown-body h1::after,
.markdown-body h2::after {
margin-top: 0.3em;
border-top: 1px solid #eaecef;
}
}

/* Fix for paragraph list items. GitHub embeds input into the first paragraph, iA Writer doesn’t. */
.markdown-body .task-list-item {
Expand Down

0 comments on commit b6538b1

Please sign in to comment.