asciidoctor-gradle-plugin icon indicating copy to clipboard operation
asciidoctor-gradle-plugin copied to clipboard

Replace {gradle-relative-srcdir} in gradle asciidoctor task configuration

Open bric3 opened this issue 6 years ago • 4 comments

Hi,

In #292 (v2.2.0) the plugin offered the nifty {gradle-relative-srcdir} attributes, however it can only be used in the documents themselves. I'm thinking that an improvement could be made to post process the attributes configured in the asciidoctor task in order to replace attributes such as {gradle-relative-srcdir} upon processing a (nested) document.

Otherwise it imposes to define in all documents attributes such as highlightjsdir and stylesdir, I'd rather write :

attributes = [
        'snippets'          : snippetsDir,
        'source-highlighter': 'highlight.js',
        'highlightjs-theme' : 'gruvbox-dark',
        'highlightjsdir'    : '{gradle-relative-srcdir}/highlight',
        'stylesheet'        : 'asciidark.css',
        'stylesdir'         : '{gradle-relative-srcdir}',
        'linkcss'           : 'true',
        'encoding'          : 'utf-8'
]

bric3 avatar Oct 17 '19 05:10 bric3

Why not use absolute paths('highlightjsdir' : '/highlight') directly.

eastack avatar Nov 15 '19 06:11 eastack

@5081 I haven't tried, but usually having a leading slash in the URL indicates the path is located at the root of a server which won't be the case where my generated doc will be located.

bric3 avatar Nov 15 '19 10:11 bric3

Acknowledged. This could be a potential feasture, but it is going to require some thinking on how to implement it.

ysb33r avatar Nov 24 '19 19:11 ysb33r

That's a good idea, I faced the very same problem today. Basically I had to put both the highlightjsdir attribute in my Gradle configuration so that it fetches a local file and in my .adoc file so that it's resolved relatively.

melix avatar Jul 15 '21 08:07 melix