Sha256: 594e4829cef68cfea66a9abe27ae5534ca8166b6f5f2ee52f7b82e35e4f287b4

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

# ------------------------------------------------------------------------------
#  ~/_plugins/asciidoctor-extensions/shout-block.rb
#  Asciidoctor extension for J1 Template
#
#  Product/Info:
#  https://jekyll.one
#
#  Copyright (C) 2019 Juergen Adams
#
#  J1 Template is licensed under the MIT License.
#  See: https://github.com/jekyll-one-org/j1_template/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

8 entries across 8 versions & 1 rubygems

Version Path
j1_template-2019.4.12 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.11 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.10 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.8 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.7 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.5 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.4 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1_template-2019.4.1 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb