Hi,

I have limited understanding on the matter and what I going to say may
not be 100% correct, but I hope it will help you to get started.

> I'd like to work on supporting macros for the asciidoctor-maven-plugin. Any
> idea on what to look at? What defines whether a macro is supported or not?
`
The ATP parser is good location to start looking at.
AptParser.MacroBlock[1] handles the macros for the APT format. I don't
think there is a flag that indicates if given `Parser` supports macros
or not. It's up to the `Parser` implementation to parse the macro
parameters and to execute the macro. So it's up to you to extract the
macro id (name) and the params for it from the Asciidoc text.

`AbstractParser#executeMacro(String macroId, MacroRequest request,
Sink sink)` [2]  will execute the macro on the given sink. So
essentially you only need to create a  MacroRequest instance and pass
it to the `executeMacro` method together with the macro id and the
sink. The MacroRequest constructor [3] takes four parameters:

* String sourceContent - this is the original content
* AbstractParser parser - a parser that could parse the sourceContent
* Map<String, Object> param - params for the macro
* File base - the current base directory

Some of the macros (such as Table of content for example) need to
parse the content again. That is why you have to pass `sourceContent`
and `parser`. Just be careful to avoid infinite recursion. There is
`AbstractParser#isSecondParsing` flag that can help you with that.
Make sure you're not executing any macros on the second parsing (or at
least that is what the APT parser is doing, Maybe there is a better
way to avoid infinite recursion or similar problems, but this should
do I think).

Hope this helps you.

Regards,
Plamen Totev

[1] 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?view=markup#l2871
[2] 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java?view=markup#l129
[3] 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroRequest.java?view=markup#l60


>
> --
> Regards, Petar!
> Karlovo, Bulgaria.
> ---
> Public PGP Key at:
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to