Sha256: fbcd2efcb4574dbdaac348683eb0e280a2c8aed5d4311171bf925e5dbe5bfda0

Contents?: true

Size: 1.12 KB

Versions: 45

Compression:

Stored size: 1.12 KB

Contents

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

45 entries across 45 versions & 1 rubygems

Version Path
j1-template-2023.9.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.9.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.9.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.8.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.8.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.8.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.7.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.6.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.5.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.5 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.4 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.3 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.4.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.3.3 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.3.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.3.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.3.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2023.2.7 lib/starter_web/_plugins/asciidoctor/shout-block.rb