Re: How to create inline macro producing HTML? (In AsciidoctorJ)

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/How-to-create-inline-macro-producing-HTML-In-AsciidoctorJ-tp8313p8337.html

Glad you got it working! That's exactly the right way to do it.

> > The create_inline_pass helper, which does exactly that, was added in Asciidoctor 2.

> How do I use it from Java? If I change the context above to "pass" then it fails with

What I was pointing out is that it is not available in AsciidoctorJ. If you set the context to pass, it is going to try to convert an inline node of type pass, which is a non-existing thing. inline pass is a parsing concept, not a document node.

> Is there some introduction to / brief overview of the API where I could learn about the available block x inline contexts and what they mean, and about the possible options and attributes?

The best resource at the moment is the integrator guide. See https://github.com/asciidoctor/asciidoctorj/blob/master/docs/integrator-guide.adoc We are working on a new documentation site for Asciidoctor where this document will be available (and likely expanded on / improved).

Best Regards,

-Dan


On Tue, Nov 3, 2020 at 1:20 AM holyjak [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi Dan, thanks a lot! This indeed works:

```clojure
(let [attrs (java.util.HashMap. {})
        opts (java.util.HashMap. {"subs" []})]
    (.createPhraseNode
      this parent, "quoted",
      (str "<abbr title=\"title\">abbreviation</abbr>")
      attrs opts))
```

Is there some introduction to / brief overview of the API where I could learn about the available block x inline contexts and what they mean, and about the possible options and attributes? I feel like a blinded person walking in a maze :-)

> The create_inline_pass helper, which does exactly that, was added in Asciidoctor 2.

How do I use it from Java? If I change the context above to "pass" then it fails with

    java.util.concurrent.ExecutionException: org.asciidoctor.jruby.internal.AsciidoctorCoreException: org.jruby.exceptions.NoMethodError: (NoMethodError) undefined method `convert_inline_pass' for #<Asciidoctor::Converter::Html5Converter:0x3227d4d1>

i.e. it is looking for `convert_inline_pass`, not `create_inline_pass`.

> Btw, an extension does not have to use the create* methods. It could just instantiate a new PhraseNode. The create* methods are just helpers.

I have looked into creating my own PhraseNode but the code that does it - https://github.com/asciidoctor/asciidoctorj/blob/6a3a38925dc2683a2ba6d3dcffd6f71c21b7c8d7/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/extension/internal/JRubyProcessor.java#L175 - is currently beyond my understanding, as it calls into the Ruby code that I do not know. And I don't know what I would gain by doing this manually so I will keep to the helpers :)

Thanks a lot!


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/How-to-create-inline-macro-producing-HTML-In-AsciidoctorJ-tp8313p8336.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux