Replacing inline macros is a tricky thing, perhaps not even possible. You
can define additional matches, but they can't overlap with matches already
made (since the substitution will have already occurred).

The best I can seem to do is look for a number in round brackets behind an
optional line comment.

Here's an example of how it would look:

[source,ruby]
--
puts "Hello, World!" # (1)
--
<1> Prints to the console

Here's the macro definition (similar to Lex's but changed to match round
brackets since the numbers in angled brackets have already been taken away)

[macros]
(?://|#|;;) ?\((?P<index>\d+)\)=callout

That accommodates line comments in C-style languages (//), scripting
languages (#) and lisps (;;).

On Mon, Sep 16, 2013 at 6:24 PM, Lex Trotman <[email protected]> wrote:

>
> On 17 September 2013 02:33, Matthew Adams <[email protected]> wrote:
>
>> Hi,
>>
>> Late to the party.
>>
>> I noticed the same thing, and would like to know if there's a way for
>> asciidoc to see patterns like "//<1>" and render *only* the code callout
>> number instead of the "//" plus the code callout number.
>>
>
> It should not be changed in Asciidoc itself since not all languages use //
> for comments.
>

I think it should. AsciiDoc should recognize well-known line comment
characters and strip them away because callouts that aren't behind line
comments cause compile errors in the code.

I've implemented line comment detection for callouts in Asciidoctor and
it's proven to be a very popular addition. It makes callouts "code
friendly".

...as a compromise, one way we could implement this without causing
breakage is to add an attribute that specifies a comma-separated list of
line comment "leaders", by default empty. These characters will be captured
and discarded when they appear in front of line comments. Taking this
approach, the risk of breaking existing documents is reduced to 0.

-Dan

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/asciidoc.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to