Sha256: 0ca73722d27d2714507583b459015befbdd6fac63b9012dc85ac40119934fb98

Contents?: true

Size: 1.12 KB

Versions: 12

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, 2024 Juergen Adams
#
# J1 Template 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
    use_dsl

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

    def process parent, reader, attributes

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

    end
  end

  block ShoutBlock
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
j1-template-2024.2.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.2.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.5 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.4 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.3 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.1.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.0.3 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.0.2 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.0.1 lib/starter_web/_plugins/asciidoctor/shout-block.rb
j1-template-2024.0.0 lib/starter_web/_plugins/asciidoctor/shout-block.rb