quoted inline_macro with a role?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
gar
Reply | Threaded
Open this post in threaded view
|

quoted inline_macro with a role?

gar

Is it possible to create an inline macro extension to achieve this pattern with the em element <em class="keyword">my term</em> from something like gloss::['my term']? I know it's possible to use a simple span element [.keyword]#my term#, but I'm just wondering if it were possible (or even desireable and intended) to add a class to another inline element because I see this line in the code:


%(#{open.chop} class="#{node.role}">#{node.text}#{close})

I can't seem to pass "role" through to the Inline constructor in the process function. (In the following, the role: role in the create_inline options does nothing.)


  inline_macro do
    named :addemph
    positional_attributes [:text, :role]
    process do |parent, target, attrs|
      if (text = attrs[:text]).nil?
        raise 'ERROR, text must be provided for the addemph::[] macro'
      end
      if (role = attrs[:role]).nil?
        role = 'my-default-role'
      end
      (create_inline parent, :quoted, text, { type: :emphasis, role: role }).render
    end
  end

It looks like Inline doesn't accept "role" as an option, only type, id, and target... unless the node.role attribute is from a higher class? If so this ruby noob doesn't know how to access it. :O) Am I using the positional_parameters correctly?


@id = opts[:id]

If I use id: role as an option, I get <em id="my-default-role">my term</em> just fine, but of course that's not what I want.

Thanks for any help!