-
Notifications
You must be signed in to change notification settings - Fork 858
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
Hide incremental slides #478
Comments
I've just hacked out this workaround, sharing in case it's useful to anyone else: function hidePrintSlides(slideshow) {
const allSlides = slideshow.getSlides();
let lastSlide;
let currentSlide;
const slidesToHide = [];
const slidesEl = document.getElementsByClassName("remark-slides-area")[0];
const slideEls = slidesEl.children;
for (let i = 0; i < allSlides.length; i++) {
lastSlide = currentSlide;
currentSlide = allSlides[i];
if (lastSlide && (
String(lastSlide.properties.continued) === "true"
||
String(currentSlide.properties.count) === "false"
)) {
const slideToHideIndex = i - 1;
slidesToHide.push(slideToHideIndex);
slideEls[slideToHideIndex].className = slideEls[slideToHideIndex].className + ' has-continuation';
}
}
} Basically call this function (passing the Then you can add a print stylesheet to your CSS to remove the slides: @media print {
.has-continuation {
display: none;
}
} |
Make sure it fires after the DOM is ready. I don't have a minimal example right now - sorry 😞 |
Would be great to have this feature somehow built in. For the next reader, I took a different approach and added a little R snippet to my presentation to create a copy of the file, use grep to remove all library("webshot")
system("cat presentation.Rmd | grep -v '^--$' > print.Rmd")
rmarkdown::render('print.Rmd', 'xaringan::moon_reader')
file_name <- paste0("file://", normalizePath("print.html"))
webshot(file_name, "git-digital-humanities.pdf")
system("rm -r print.Rmd print.html print_files") |
Looks like there might have been a change to the way the
to
Anyway, the following full example seems to work for me with this change:
I haven't tested it extensively, but the only quirk I've noticed so far is that you get an extra blank page at the end of the PDF. I hope that's useful. |
@DavidAntliff thanks for your instructions! Unfortunately, they don't work for me as expected. I have
And it prints all the overlayed pages. Also, the size is wrong. |
@ulysses4ever strange, I am only able to test on Ubuntu 16.04/Chrome 69 and Mac OSX 10.12.6/Chrome 68, but in both cases it seems to work for me. Only difference seems to be that on my Mac I don't get a blank page at the end. The size is another issue and might be helped by #50 (comment) |
JS code borrowed from gnab/remark#478
I think @DavidAntliff was correct: @benjie's original code contained a little bug. Here is my "old-school" JS code, which also tries to inject the CSS to (function(d) {
var el = d.getElementsByClassName("remark-slides-area");
if (!el) return;
var slide, slides = slideshow.getSlides(), els = el[0].children;
for (var i = 1; i < slides.length; i++) {
slide = slides[i];
if (slide.properties.continued === "true" || slide.properties.count === "false") {
els[i - 1].className += ' has-continuation';
}
}
var s = d.createElement("style");
s.type = "text/css";
s.innerHTML = "@media print { .has-continuation { display: none; } }";
d.head.appendChild(s);
})(document); |
I used this workaround: |
Not sure why this is still open with two workarounds listed here. Should we close the issue? |
With remark.js 0.15.0, you no longer need the workarounds, because 2951555 introduced a CSS class to incremental slides, so you can define CSS rules to hide these slides easily. However, the current "latest" release of remark.js is still 0.14.1 because 0.15.0 also introduced some breaking changes (6e2325d). |
It would be nice to have documentation (for every corresponding release) for this particular use case: when I'm using incremental slides markup ( |
Thanks very much for remark.js: I use it extensively when preparing lecture material for courses that I teach (see, e.g., http://www.engr.mun.ca/~anderson/teaching/3891/lecture).
I like to use incremental builds in the classroom, but when I distribute PDF versions of the lecture notes (slides + presenter notes with CSS to turn key words into blank spaces for students to fill in) I don't want to show all of the incremental steps. My current workflow requires me to manually go through the PDF output from Chrome's "Print to PDF" and delete all of the intermediate pages. This is a labour-intensive, slightly error-prone process. It would be really handy if I could run remark in a mode that only showed the final version of each complete (non-incremental) slide.
The text was updated successfully, but these errors were encountered: