Skip to content

Adding Ruby extensions inline #61

@twogee

Description

@twogee

I would like to add a custom extension to the Ant task using inline Ruby like this

<asciidoctor ...>
<inlineMacroProcessor>
<![CDATA[
   use_dsl
 
   named :man
   name_positional_attributes 'volnum'

   def process parent, target, attrs
     text = manname = target
     suffix = ''
     target = %(#{manname}.html)
    suffix = if (volnum = attrs['volnum'])
    "(#{volnum})"
  else
    nil
  end
  if parent.document.basebackend? 'html'
    parent.document.register :links, target
    %(#{(create_anchor parent, text, type: :link, target: target).render}#{suffix})
  elsif parent.document.backend == 'manpage'
    %(\\fB#{manname}\\fP#{suffix})
  else
    %(#{manname}#{suffix})
  end
end
]]>
</inlineMacroProcessor>
</asciidoctor>

(the code would be wrapped as a class extending Extensions::InlineMacroProcessor and registered as an extension).

The idea is to avoid compiling an extension Java class and adding it to the classpath.
Would it be possible?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions