How can i include text snippet with image more then once? [SOLVED]

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

How can i include text snippet with image more then once? [SOLVED]

Hoplop
This post was updated on .
So i have separate file with content like this:

Some text
(<<id1>>)
+
[[id1]]
.Image title
image::image1.png[]

In my main document i have to include those snippet few times like this:

include::snippet.adoc[]

The problem is that when i try to build PDF, i get errors

asciidoctor: WARNING: main.adoc: line 24: id assigned to block already in use: id1

What can i do in this situation?

Reply | Threaded
Open this post in threaded view
|

Re: How can i include text snippet with image more then once?

Hoplop
I tried to solve this by using variables in image ID and changing its value each time before include:

in snippet.adoc:

Some text
(<<{id_variable}>>)
+
[[{id_variable}]]
.Image title
image::image1.png[]

in main.adoc:

Some text some text some text

:id_variable: _first-include
include::snippet.adoc[]

Another text another text another text

:id_variable: _second-include
include::snippet.adoc[]

BUT it does not work. Probably, asciidoctor doesn't allow using of variables in id's...
Any help?
Reply | Threaded
Open this post in threaded view
|

Re: How can i include text snippet with image more then once?

Alexander Schwartz
There is an alternative syntax for IDs that works for me on Asciidoctor 2.0.10. Instead of double-braces I used single braces and a hash:

[#{id_variable}]
.Image title
image::image1.png[]

After that change the examples seemed to work for me.
Alexander Schwartz (alexander.schwartz@gmx.net)
https://www.ahus1.de
Reply | Threaded
Open this post in threaded view
|

Re: How can i include text snippet with image more then once?

Hoplop
Wow, now it works, thanks!
Ah, by the way, maybe you know: is it possible to do simple calculations with variables values? Like, for example:

:variable1: 21
:variable2: {variable1} - 1

This should say "20": {variable2}
Reply | Threaded
Open this post in threaded view
|

Re: How can i include text snippet with image more then once?

mojavelinux
Administrator
In reply to this post by Alexander Schwartz
> There is an alternative syntax for IDs that works for me on Asciidoctor 2.0.10. Instead of double-braces I used single braces and a hash:

Exactly correct! The legacy double bracket syntax for IDs doesn't support attribute references for compatibility reasons. (See https://github.com/asciidoctor/asciidoctor/issues/1381).

Best,

-Dan

On Wed, Nov 13, 2019 at 6:35 AM Alexander Schwartz [via Asciidoctor :: Discussion] <[hidden email]> wrote:
There is an alternative syntax for IDs that works for me on Asciidoctor 2.0.10. Instead of double-braces I used single braces and a hash:

[#{id_variable}]
.Image title
image::image1.png[]

After that change the examples seemed to work for me.
Alexander Schwartz ([hidden email])
https://www.ahus1.de



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/How-can-i-include-text-snippet-with-image-more-then-once-tp7350p7352.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: How can i include text snippet with image more then once?

mojavelinux
Administrator
In reply to this post by Hoplop
> is it possible to do simple calculations with variables values?

No, that is not possible.

Best,

-Dan

On Thu, Nov 14, 2019 at 1:38 AM Hoplop [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Wow, now it works, thanks!
Ah, by the way, maybe you know: is it possible to do simple calculations with variables values? Like, for example:

:variable1: 21
:variable2: {variable1} - 1

This should say "2": {variable2}



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/How-can-i-include-text-snippet-with-image-more-then-once-tp7350p7353.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux