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'd like to be able to replace attributes everywhere in my document. but i don't want to have to repeat the subs="attributes+" in every single block i define. how do i do that?
ditto for other things. all my images have the [.thumb] decorator. is there a way to not have to specify it individually for each image, but rather, globally? thanks in advance, / eitan |
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'm also curious to know why no substitution of attributes is the default for code blocks. i can imagine many situations where authors are writing instructions that are parameterized. anyhow..
|
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 post was updated on Feb 16, 2017; 6:20pm.
Edit: removed the comment since I was miss-interpreting the issue.
|
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
|
What we're talking about here is different from https://github.com/asciidoctor/asciidoctor/issues/1061, which I just wrote in a comment. You're both correct that there's currently no mechanism available in the AsciiDoc source to change the substitutions for a type of block globally. That is something we could add. However, it is still possible to achieve this using the extension facility. You could use a Treeprocessor to visit every source block and add the attributes substitution to the block. The Treeprocessor executes before substitutions are performed on the block, so it's the perfect opportunity. You could even program the Treeprocessor so it is driven by the AsciiDoc source. For instance, you can define an attribute in your document named `source-subs` as follows: :source-subs: attributes+ Then, the Treeprocessor can visit all the source blocks and set the subs just as though subs=attributes+ was set on every block explicitly. You can do the same thing to apply roles to blocks as well. I want to end by commenting on why subs=attributes+ isn't, and shouldn't be, the default on verbatim blocks (source, listing, literal). The expectation is that the contents in those blocks is output verbatim. If we started performing substitutions on that content by default, then we'd break the contract and cause unexpected behavior for a lot of users. For instance, Ruby and Groovy source code would get mangled since both uses the syntax {variable} to interpolate strings. (A lesser reason is that it would slow down the processor). -Dan On Thu, Feb 16, 2017 at 8:16 AM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote: I fear there's no way to achieve what you want, but there's a conversation about that in the GitHub repo https://github.com/ 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 |
Administrator
|
In reply to this post by abelsromero
Keep in mind that while it may be annoying to have to repeat metadata on each block, that information is often semantic so it actually belongs there. I could see where a global setting on the document makes sense, but I would caution from applying it without any reference in the document because then the document doesn't tell the whole story. If the information is not semantic, and it's just needed for styling the output (i.e., publishing), then I would argue it doesn't belong in the document at all and should be added by a Treeprocessor or a custom converter. -Dan On Thu, Feb 16, 2017 at 11:09 AM, Dan Allen <[hidden email]> wrote:
... [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 for the very informative reply and for pointing me to a solution! / eitan
|
Free forum by Nabble | Edit this page |