Text formatting embedded in attribute value

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

Text formatting embedded in attribute value

jljouannic
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:

:app-name: MyApp^(C)^

Is there a way to make it look like MyApp© and not MyApp^©^ in the output?

JL
Reply | Threaded
Open this post in threaded view
|

Re: Text formatting embedded in attribute value

mojavelinux
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,

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:

:app-name: MyApp^(C)^

Is there a way to make it look like MyApp© and not MyApp^©^ in the output?

JL


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Text-formatting-embedded-in-attribute-value-tp1322.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Text formatting embedded in attribute value

jljouannic
Thank you for this really complete answer!
Reply | Threaded
Open this post in threaded view
|

Re: Text formatting embedded in attribute value

jljouannic
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?

Reply | Threaded
Open this post in threaded view
|

Re: Text formatting embedded in attribute value

mojavelinux
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:

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?




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Text-formatting-embedded-in-attribute-value-tp1322p3042.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--