Sha256: ea35d7fc03143cb39c114483f01c3b70e7887e244a0c3d7e61fa74fde10381dd

Contents?: true

Size: 1.14 KB

Versions: 27

Compression:

Stored size: 1.14 KB

Contents

# ------------------------------------------------------------------------------
#  ~/_plugins/asciidoctor-extensions/shout-block.rb
#  Asciidoctor extension for J1 Template
#
#  Product/Info:
#  https://jekyll-one.com
#
#  Copyright (C) 2019 Juergen Adams
#
#  J1 Template is licensed under the MIT License.
#  See: https://github.com/jekyll-one/j1_template_mde/blob/master/LICENSE
#
# ------------------------------------------------------------------------------
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

PeriodRx = /\.(?= |$)/

# An extension that transforms the contents of a paragraph
# to uppercase.
#
# Usage
#
#   [shout, 5]
#   Time to get a move on.
#
Asciidoctor::Extensions.register do

  class ShoutBlock < Extensions::BlockProcessor
#    PeriodRx = /\.(?= |$)/

    use_dsl

    named :shout
    on_context :paragraph
    name_positional_attributes 'vol'
    parse_content_as :simple

    def process parent, reader, attrs
      volume = ((attrs.delete 'vol') || 1).to_i
      create_paragraph parent, (reader.lines.map {|l| l.upcase.gsub PeriodRx, '!' * volume }), attrs
    end
  end

  block ShoutBlock

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
j1_template_mde-2018.4.36 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.35 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.34 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.33 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.32 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.31 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.30 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.29 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.28 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.27 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.26 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.25 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.24 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.23 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.22 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.21 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.20 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.19 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.18 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template_mde-2018.4.17 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb