Class: HTML5RubyMacro

Inherits:
Extensions::InlineMacroProcessor
  • Object
show all
Defined in:
lib/asciidoctor-html5ruby/extension.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, target, attributes) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/asciidoctor-html5ruby/extension.rb', line 9

def process parent, target, attributes
  if attributes.size == 2 and attributes.key?(1) and attributes.key?("rpbegin")
    # for example, html5ruby:楽聖少女[がくせいしょうじょ]
    rt = attributes[1]
    rt ||= ""
    rpbegin = '('
    rpend = ')'
  else
    rpbegin = attributes['rpbegin']
    rt = attributes['rt']
    rpend = attributes['rpend']
  end

  %(<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt><rp>#{rpend}</rp></ruby>)
end