首页 > 解决方案 > 使用 Rake 时使用 Reveal.js 作为 Asciidoctor 后端

问题描述

我想在Asciidoctor Reveal.js的帮助下创建一些幻灯片,并认为使用 Rake 构建我的幻灯片就足够了。但我要 s****d 将 Reveal.js 设置为 Asciidoctor 的后端。

require 'asciidoctor'

task default: %w[html5]

MASTER_FILENAME='slides.adoc'
OUTPUT_FILENAME='index.html'

task :html5 do
  puts "Source is #{MASTER_FILENAME}"

  begin
    Asciidoctor.convert_file MASTER_FILENAME,
                             safe: :safe,
                             to_file: OUTPUT_FILENAME
                             backend: 'revealjs'

    puts "\t#{OUTPUT_FILENAME} created"
  rescue StandardError => e
    puts "\t" +  e.message
  end
end

任何建议如何启用 Reveal.js 作为后端?

标签: rubyrakeasciidoctorasciidoctor-revealjs

解决方案


Reveal.js 本身并不是 Asciidoctor 的后端。

asciidoctor-reveal.js是一个转换器,它协调将 Asciidoctor 源文件转换为使用 Reveal.js 的 HTML。通过使用 asciidoctor.js,asciidoctor-reveal.js可以在运行时注册为 asciidoctor.js 后端(它对基于 Ruby 的asciidoctor命令行工具没有影响)。

您需要调整您的 rake 处理以遵循此处的说明:https ://asciidoctor.org/docs/asciidoctor-revealjs/#node-javascript-setup


推荐阅读