Sha256: a424c221f2c17298db079562e0387512eb5a29aecaf3a03b29c29580a2521adf

Contents?: true

Size: 1000 Bytes

Versions: 3

Compression:

Stored size: 1000 Bytes

Contents

# This helper file borrows from the Bespoke converter
# https://github.com/asciidoctor/asciidoctor-bespoke
require 'asciidoctor'
require 'json'

if Gem::Version.new(Asciidoctor::VERSION) <= Gem::Version.new('1.5.3')
  fail 'asciidoctor: FAILED: reveal.js backend needs Asciidoctor >=1.5.4!'
end

unless defined? Slim::Include
  fail 'asciidoctor: FAILED: reveal.js backend needs Slim >= 2.1.0!'
end

# This module gets mixed in to every node (the context of the template) at the
# time the node is being converted. The properties and methods in this module
# effectively become direct members of the template.
module Slim::Helpers

  EOL = %(\n)
  SliceHintRx = /  +/

  def slice_text str, active = nil
    if (active || (active.nil? && (option? :slice))) && (str.include? '  ')
      (str.split SliceHintRx).map {|line| %(<span class="line">#{line}</span>) }.join EOL
    else
      str
    end
  end

end

# More custom functions can be added in another namespace if required
#module Helpers
#end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-revealjs-1.0.2 templates/slim/helpers.rb
asciidoctor-revealjs-1.0.1 templates/slim/helpers.rb
asciidoctor-revealjs-1.0.0 templates/slim/helpers.rb