Hi all,
If I put some markup in a custom attribute, is there a way to see, in the output, the corresponding text formatting everywhere the attribute is used? For example, if I define the following attribute at the beginning of my document:
Is there a way to make it look like MyApp© and not MyApp^©^ in the output? JL |
Administrator
|
Hey there JL! The syntax you are looking for is the pass:[] inline macro. This macro has special meaning in an attribute entry. It allows the substitutions to be applied at the time the attribute is defined. Otherwise, as you have observed, the formatting doesn't get picked up due to the default order in which substitutions are applied (text formatting comes before attribute replacement, see [1]).
The pass inline macro accepts a list of substitutions in the "target" slot. In your case, you are interested in the "quotes" substitutions (quotes in this case means text formatting).
```asciidoc :app-name: pass:quotes[MyApp^(C)^] ``` If you are using Asciidoctor 1.5.0.preview.1, you can specify the substitution using the single-character alias, q.
```asciidoc :app-name: pass:q[MyApp^(C)^] ``` Another approach is to change the order of substitutions that are applied where the attribute is referenced. For example, you might do:
```asciidoc :app-name: MyApp^(C)^ [subs="specialcharacters,attributes,quotes,replacements,macros,post_replacements"]
The application is called {app-name}. ``` Your post made me realize that this feature of AsciiDoc is not documented in the Asciidoctor user manual. It belongs in the attribute entry section. I'll make sure it gets documented.
Cheers, -Dan On Tue, Jan 28, 2014 at 6:37 AM, jljouannic [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi all, Dan Allen | http://google.com/profiles/dan.j.allen |
Thank you for this really complete answer!
|
In reply to this post by mojavelinux
It's been a year and a half, and this question comes back from the dead solved. The attribute entry substitution as described in the documentation works perfectly except for titles. Using the same example as in my original post, if I define an attribute and use it later in a title: :app-name: MyApp^(C)^ ... === {app-name} It is rendered like this: 1.1. MyApp(C)As you can notice, the substitution is partial. (C) is not replaced by ©, but it is superscripted as expected. The problem is the same with other characters mentioned in the documentation. What am I doing wrong? |
Administrator
|
What you are looking for is the following solution: ---- :app-name: pass:q,r[MyApp^(C)^] == {app-name} ---- (q = quotes, r = replacements) You need to preemptively force both the quotes and replacement substitutions. The order of substitutions is different for titles, which is why you need to add "r" if you plan to use the attribute in a title, but you didn't need it when using the attribute in a paragraph. This is one of those weird quirks of AsciiDoc that we hope to address in the future. For now, it's best to define the attribute with the substitution you want applied at the time you define it so it works universally. Cheers, -Dan On Mon, Apr 27, 2015 at 6:52 AM, jljouannic [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |