Attributes with dots.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Attributes with dots.

paranoiabla
Hello,

in my maven pom.xml I have a lot of properties defined like this:
-------
    <properties>
        <prop>value</prop>
        <amazon.aws.sdk.version>1.10.27</amazon.aws.sdk.version>
        <asciidoctor.version>1.5.4-SNAPSHOT</asciidoctor.version>
        <asciidoctorj.diagram.version>1.3.1</asciidoctorj.diagram.version>
-------

Now I want to have access to these properties when building my documentation with the asciidoctor-maven-plugin. I managed to patch the plugin to pass these properties as attributes and sure enough {prop} gets replaced by value. However my problem is with attributes that contain dots  - for example {amazon.aws.sdk.version} is never replaced by 1.10.27.  I also tried setting an attribute in the header like this:

= Introduction
Petar Tahchiev
:doctype: book
:sectanchors:
:sectlinks:
:toclevels: 4
:source-highlighter: coderay
:icons: font
:last-update-label!:
:blah.blah: ../../../modules

The {blah.blah} is.....

but again {blah.blah} is never replaced. How can I overcome this?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes with dots.

Jeremie Bresson
As far as I know the AsciiDoc variables that are available and defined in the pom are set in:

build > plugins > plugin (node corresponding to asciidoctor-maven-plugin) > configuration > attributes (see Lines 47-49 of in the to-html example pom)
or
build > plugins > plugin (node corresponding to asciidoctor-maven-plugin) > executions > execution > configuration > attributes (see Lines 112-119 of in the to-html example pom)

Have you tried to write something like that?
<attributes>
    <blah.blah>${some.maven.property}</blah.blah>
    <!-- ... -->
</attributes>
Reply | Threaded
Open this post in threaded view
|

Re: Attributes with dots.

paranoiabla
No I haven't. But in my case I have more than 130 maven properties set (Plus the ones from spring-platform-bom which I'm extending). I don't want to have them duplicated in the bom and also in the maven-plugin declaration.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes with dots.

abelsromero
Keeping maven integration a apart, I have run some tests and it's clear that properties with dots are not recognized.
Other separators like '-' or '_' work, others like ' ', '\' don't.

Even when the documentation always uses '-', there's nothing about what formats are recognized and which aren't. And to tell the truth according to the code and my understanding of it, dots should work. So, untill Dan says another thing I would regard this as a bug, but maybe there's another reason why they do not work.
Reply | Threaded
Open this post in threaded view
|

Re: Attributes with dots.

mojavelinux
Administrator

Keeping maven integration a apart, I have run some tests and it's clear that properties with dots are not recognized.

That's correct. A dot is not a valid attribute name character in AsciiDoc. And we are continuing to reserve them for referencing properties. (See https://github.com/asciidoctor/asciidoctor/issues/528).
 
Other separators like '-' or '_' work, others like ' ', '\' don't.

An attribute must start with a word character and only consist of word characters or hyphens. Basically, it's the same as a variable in most program languages, except it also allows hyphens after the first character and it only supports Basic Latin letters. (See https://github.com/asciidoctor/asciidoctor/issues/1665).
 

Even when the documentation always uses '-', there's nothing about what formats are recognized and which aren't.

We probably should document this in the user manual. (See https://github.com/asciidoctor/asciidoctor.org/issues/444).

paranoiabla, My recommendation for your patch is to replace dot with hyphen (or underscore) in the name when you generate the attribute.

> but again {blah.blah} is never replaced. How can I overcome this?

Use {blah-blah} (after updating your patch to generate the attribute this way).

-Dan

--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Attributes with dots.

paranoiabla
Thanks mojavelinux,

here's the pull-request:

https://github.com/asciidoctor/asciidoctor-maven-plugin/pull/192