Sha256: 474e5d368902b6303cd79933108f990a32237fefdef4a6f89f613de0239be397

Contents?: true

Size: 1.13 KB

Versions: 38

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) 2022 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

38 entries across 38 versions & 1 rubygems

Version Path
j1-template-2022.6.3 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2022.6.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2022.6.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2022.6.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2022.5.3 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.2 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.1 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.1.rc1 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.1.rc0 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0.rc4 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0.rc3 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0.rc2 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0.rc1 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.5.0.rc0 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.4.10 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.4.9 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.4.8 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.4.7 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb
j1-template-2022.4.6 lib/starter_web/_plugins/asciidoctor-extensions/shout-block.rb