forked from asciidoctor/asciidoctor-extensions-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shout-block.rb
40 lines (35 loc) · 1.1 KB
/
shout-block.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
RUBY_ENGINE == 'opal' ? (require 'shout-block/extension') : (require_relative 'shout-block/extension')
Extensions.register do
# defined as a qualified class name
#block '::ShoutBlock', :shout
#block '::ShoutBlock'
# defined as class
#block ShoutBlock, :shout
block ShoutBlock
# defined as instance
#block ShoutBlock.new, :shout
#block ShoutBlock.new
# defined as block
#block do
# PeriodRx = /\.(?= |$)/
# named :shout
# on_context :paragraph
# parse_content_as :simple
# name_attributes 'vol'
# process do |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
# defined as block with lambda as argument to process
#block do
# named :shout
# on_context :paragraph
# parse_content_as :simple
# name_attributes 'vol'
# 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