Sha256: 6c44422c42fc1cdab2a3b2f16b6418ff4d40691f671b51e69fa8421910ce47b3

Contents?: true

Size: 1.13 KB

Versions: 26

Compression:

Stored size: 1.13 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/shout-block.rb
# Asciidoctor extension for J1 Template
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2020 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

26 entries across 26 versions & 1 rubygems

Version Path
j1-template-2021.0.0 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.25 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.24 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.22 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.21 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.20 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.19 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.18 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.17 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.16 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.15 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.14 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.13 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.12 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.11 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.10 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.9 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.8 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.7 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2020.0.6 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb