https://discuss.asciidoctor.org/Bold-Source-Code-and-Escaping-tp464p475.html
Rob,
Aha! I see that I missed the special case. The circumstances here require that we get into a little bit of yak shaving. You'll be quite surprised that it's very solvable.
I've come up with not one, but two solutions to the challenge. First, we'll finish the solution you started.
1. Double dollar escaping
You are correct to think that the double dollar will escape the second occurance of ** to allow the bold to stretch the whole line. In your case, though, the double dollar is not used because it's a macro and macros are not enabled on your pass:[] macro. Thus, simply enabling macros using pass:verbatim,quotes,macros[] will allow it to work (technically the verbatim isn't needed here since there's nothing to escape).
[source,java]
[subs="verbatim,macros"]
----
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
pass:verbatim,quotes,macros[**.antMatchers("/resources/$$**$$").permitAll()**]
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
----
TIP: You can also use triple plus instead of double dollar, which is even more strict about escaping.
2. Use an empty attribute to interrupt the markup
Since the ** is closing your span of bold text, you can use an attribute to get in between the two asterisks and keep them apart during parsing:
[source,java]
[subs="verbatim,macros"]
----
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
pass:verbatim,quotes,attributes[**.antMatchers("/resources/\*{empty}*").permitAll()**]
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
----
NOTE: You still need to escape the bold marks around {empty} or else it will bold the empty text.
Of course, now that I realize you are talking about escpaing formatting, and not turning on the formatting on a per-line basis, you can just skip the pass macro and enable quotes and macros on the whole block.
[source,java]
[subs="verbatim,quotes,macros"]
----
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
**.antMatchers("/resources/$$**$$").permitAll()**
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
----
Btw, to save some typing and ensure consistency, I recommend making the substitution set an attribute on the document:
:markup-in-source: verbatim,quotes,macros
[source,java]
[subs="{markup-in-source}"]
----
...
----
Btw, a totally different solution to this problem (in the upcoming Asciidoctor 0.1.4) is to to introduce a Treeprocessor extension that goes through all source code blocks (or ones marked with a certain role) and look for special markup which indicates the line should be emphasized in some way. For instance, you could type it as:
[source,java]
----
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll() // (*)
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
----
The Treeprocessor would examine the contents looking for the "// (*)" suffix and rewrite the line so that Asciidoctor will format it appropriately. This is probably more of a long-term approach to keep the docs simple. What's great about Asciidoctor is that hints like these are very possible...all with the aim of keeping docs as simple and clean as possible.
-Dan