简体   繁体   English

从在ioslides中启用的高亮模式开始

[英]Start with highlight mode enabled in ioslides

In ioslides presentation with Rmarkdown, there is an option to enable highlight mode in each slide by pressing h . 在带有Rmarkdown的ioslides演示中,有一个选项可以通过按h启用每张幻灯片中的高亮模式 Is there some way to make the highlight mode enabled by default and disable it by pressing h . 有什么方法可以使高亮模式默认为启用,然后按h禁用它。

There is no built-in option to enable highlight mode by default. 没有内置选项默认情况下启用突出显示模式。
This comes from these lines of JavaScript: here and here . 这来自这些JavaScript行: herehere
Highlight mode is removed when the speaker changes the slide. 当扬声器更改幻灯片时,高光模式将被删除。

However, there is a hacky way to highlight each slide by default. 但是,默认情况下,有一种方法可以突出显示每张幻灯片。
In your project, create a new file (named for instance highlight.html ). 在您的项目中,创建一个新文件(例如命名为highlight.html )。
In this file, copy the following content: 在此文件中,复制以下内容:

<script type="text/javascript">
  SlideDeck.prototype.prevSlide = function(opt_dontPush) {
    if (this.curSlide_ > 0) {
      var bodyClassList = document.body.classList;
      bodyClassList.add('highlight-code');

      // Toggle off speaker notes if they're showing when we move backwards on the
      // main slides. If we're the speaker notes popup, leave them up.
      if (this.controller && !this.controller.isPopup) {
        bodyClassList.remove('with-notes');
      } else if (!this.controller) {
        bodyClassList.remove('with-notes');
      }

      this.prevSlide_ = this.curSlide_--;

      this.updateSlides_(opt_dontPush);
    }
  };

  SlideDeck.prototype.nextSlide = function(opt_dontPush) {
    if (!document.body.classList.contains('overview') && this.buildNextItem_()) {
      return;
    }

    if (this.curSlide_ < this.slides.length - 1) {
      var bodyClassList = document.body.classList;
      bodyClassList.add('highlight-code');

      // Toggle off speaker notes if they're showing when we advanced on the main
      // slides. If we're the speaker notes popup, leave them up.
      if (this.controller && !this.controller.isPopup) {
        bodyClassList.remove('with-notes');
      } else if (!this.controller) {
        bodyClassList.remove('with-notes');
      }

      this.prevSlide_ = this.curSlide_++;

      this.updateSlides_(opt_dontPush);
    }
  };
</script>

Now, modify the YAML header of the ioslides presentation: 现在,修改ioslides演示文稿的YAML标头:

---
title: "Highlighted"
author: "Romain Lesur"
date: "26/06/2018"
output: 
  ioslides_presentation:
    includes:
      after_body: highlight.html
---

It should do the trick. 它应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM