Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hello,
Is there a way to process a document such as the one below, without getting a warning? The difficulty here is to mix shell variables (using the ${var} notation is a requirement) with asciidoctor attributes in the same block. The final output is fine, but I am getting a lot of warnings and sorting out which ones matter (actually missing asciidoctor attributes) and which one don't (shell variables) is not always easy. # Test :attribute-missing: warn :ADOC_ATTR: asciidoctor [subs="attributes"] ---- SHELL_VAR="shell" echo {ADOC_ATTR} ${SHELL_VAR} ---- In this case, the output is: asciidoctor: WARNING: skipping reference to missing attribute: shell_var Thanks. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
This works for me:
:attribute: attr [source,shell,subs=attributes] ---- ATTR=asciidoctor echo {attribute} $\{ATTR} ---- David Jencks > On Feb 27, 2020, at 1:54 AM, halol [via Asciidoctor :: Discussion] <[hidden email]> wrote: > > Hello, > > Is there a way to process a document such as the one below, without getting a warning? > > The difficulty here is to mix shell variables (using the ${var} notation is a requirement) with asciidoctor attributes in the same block. The final output is fine, but I am getting a lot of warnings and sorting out which ones matter (actually missing asciidoctor attributes) and which one don't (shell variables) is not always easy. > > # Test :attribute-missing: warn :ADOC_ATTR: asciidoctor [subs="attributes"] ---- SHELL_VAR="shell" echo {ADOC_ATTR} ${SHELL_VAR} ---- > > In this case, the output is: > asciidoctor: WARNING: skipping reference to missing attribute: shell_var > > Thanks. > > If you reply to this email, your message will be added to the discussion below: > https://discuss.asciidoctor.org/skipping-reference-to-missing-attribute-tp7687.html > To start a new topic under Asciidoctor :: Discussion, email [hidden email] > To unsubscribe from Asciidoctor :: Discussion, click here. > NAML ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by halol
The warning is controlled by the attribute-missing attribute. By default, the value is "skip", which produces no warning for a missing attribute (and leaves it as typed). To get a warning, you must set attribute-missing to "warn". So check your settings to see what value is being used and adjust accordingly. Best, -Dan On Thu, Feb 27, 2020 at 2:54 AM halol [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hello, ... [show rest of quote] -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I think the point is that he wants ${foo} to be the shell literal, not a (missing) asciidoc attribute reference. So escaping the ${ as $\{ prevents asciidoc from interpreting the { in ${ as the start of an attribute.
David Jencks
... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Yes, both are valid options. You can either escape it or disable the warnings. -Dan On Thu, Feb 27, 2020, 12:14 David Jencks [via Asciidoctor :: Discussion] <[hidden email]> wrote: I think the point is that he wants ${foo} to be the shell literal, not a (missing) asciidoc attribute reference. So escaping the ${ as $\{ prevents asciidoc from interpreting the { in ${ as the start of an attribute. ... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by David Jencks
Btw, never use subs=attributes It should be subs=attributes+. Otherwise, special characters won't be escaped and it will produce broken HTML. On Thu, Feb 27, 2020, 12:17 Dan Allen <[hidden email]> wrote:
... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by mojavelinux
They have really different effects. Consider:
:ambiguous: asciidoctor [source,shell,subs=attributes+] ---- ambiguous=shell echo {ambiguous} ${ambiguous} —— not that this is a good idea…. but what if in his example someone later edited the .adoc to define, :SHELL_VAR: now an asciidoc attribute! David Jencks
... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
I agree they're different. I expect the writer to know which one is best for them. I'm just offering the options. -Dan On Thu, Feb 27, 2020 at 12:26 PM David Jencks [via Asciidoctor :: Discussion] <[hidden email]> wrote: They have really different effects. Consider: ... [show rest of quote] -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thank you both for your replies.
Escaping the shell variable is indeed what I need, and I now feel a bit dumb for not thinking about it before. Specially since I have been struggling with the opposite problem: attributes being escaped when I don't want them to be. For example: :folder_name: Path [source,shell,subs=attributes+] ---- D:\Windows\{folder_name} ----Which very obviously doesn't produce the expected results. That should have given me the solution to my current problem! And I take good note of the comment regarding subs=attributes. Thanks again. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In case you haven’t discovered this already….
:folder_name: Path David Jencks
... [show rest of quote] |
Free forum by Nabble | Edit this page |