Login  Register

Re: Bold Source Code and Escaping

Posted by mojavelinux on Aug 19, 2013; 10:06pm
URL: https://discuss.asciidoctor.org/Bold-Source-Code-and-Escaping-tp464p469.html


Rob,

As you have cited, custom substitutions are supported on the source block (and any block, for that matter):

[source,java]
[subs="verbatim,quotes"]
----
System.out.println("Hello *bold* text").
----

If you want to enable the quotes in an ad-hoc way, then you'll want to enable macros on the block and use the inline pass:[] macro, which allows substitutions to be specified:

[source,java]
[subs="verbatim,macros"]
----
System.out.println("No *bold* here");
pass:verbatim,quotes[System.out.println("Hello *bold* text");]
----

Unfortunately, this introduces additional markup into the Java source that makes it invalid in raw form...though the output it produces will be valid. So, hopefully it gets you by today.

An idea that stems from this is to allow the substitutions to be enabled on a given line from outside the source code. That's probably best handled in a BlockProcessor (coming in 0.1.4) or a BlockFilter (planned for the subsequent release).

Let me know if that works for you, or if you need more info.

Cheers,

-Dan


On Mon, Aug 19, 2013 at 11:33 AM, rwinch [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thank you for the quick reply.

I think something like this would be valuable. Do you think this feature might be considered for a future release? It seems like the support is most of the way there. For example, the following renders as "Hello <strong>bold</strong>" as I would expect:

.MyCode.java
[source,java]
[subs="verbatim,quotes"]
----
Hello *bold*
----

The only thing that appears to be missing is toggling on/off "quotes" within the snippet.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Bold-Source-Code-and-Escaping-tp464p466.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | http://google.com/profiles/dan.j.allen