Начните с включенного режима подсветки в ioslides - PullRequest
0 голосов
/ 26 июня 2018

В ioslides презентации с Rmarkdown, есть возможность включить режим подсветки на каждом слайде, нажав h.Есть ли способ сделать режим подсветки включенным по умолчанию и отключить его, нажав h.

1 Ответ

0 голосов
/ 26 июня 2018

Нет встроенной опции для включения режима выделения по умолчанию.
Это происходит из следующих строк JavaScript: здесь и здесь .
Режим выделения выделяется, когда динамик меняет слайд.

Однако по умолчанию есть хакерский способ выделить каждый слайд.
В вашем проекте создайте новый файл (например, с именем highlight.html).
В этом файле скопируйте следующее содержимое:

<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>

Теперь измените заголовок YAML презентации ioslides:

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

Это должно сработать.

...