asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
617 stars 172 forks source link

Custom Macro #1247

Closed sfali23 closed 7 months ago

sfali23 commented 7 months ago

Hi There,

I am trying to write a macro, the idea behind the macro is follows:

The macro will be reading from a XML file:

<book>
  <chapter index="1">
       <line index="1" text="some line text"/>
  </chapter>
</book

The macro will be called as follows: my_macro::target[chapter=1, line=1, tokens="2-3"]

The macro will retrieved the text from given chapter and line and suppose to insert the text. If tokens attribute is present it is supposed to highlight corresponding tokens (in this example line text will be highlighted).

Most of the time macro will be included in a table cell. Following is the code snippet of the block macro:

int chapterNumber = Integer.parseInt((String) attributes.get("chapter"));
int lineNumber = Integer.parseInt((String) attributes.get("line"));
return createBlock(parent, "paragraph", searchEngine.find(chapterNumber, lineNumber).getValue(), attributes);

The problem is macro doesn't get processed within a table cell but it does get processed if it is outside of table.

Second question is how can I make text highlight.

Thanks in advance.

Regards,

Syed

robertpanzer commented 7 months ago

This looks like a usage problem. Please address this first in the project chat at https://asciidoctor.zulipchat.com