Lex: very much appreciate the reply. I just wanted to sanity check
that I wasn't doing anything crazy. Thanks!

On Wed, Aug 1, 2012 at 8:10 PM, Lex Trotman <[email protected]> wrote:
> On 1 August 2012 23:19, Chris Strom <[email protected]> wrote:
>> I'm trying to make use of code snippets -- small chunks from a larger
>> file. I'm using sed for this with the sys macro, but I'm wondering if
>> there is a better way.
>>
>> For what it's worth, my sed snippets print regex ranges (from the line
>> containing X to the line containing Y), for example:
>>
>> [source,javascript]
>> ----
>> sys::[sed -n '/the game/I,/add(body)/ p' 
>> includes/building_an_avatar/avatar.js]
>> ----
>>
>> I can then do a regular include later for the "let's see the whole
>> thing" summary. The benefit being that I only have to change things in
>> one place and can run unit tests -- even for snippets that might not
>> otherwise compile.
>>
>> Is there a better way to accomplish the same thing? I'm a little
>> concerned with cases when a code change results in empty sed output.
>> I'm also unsure if there may be something that I'm overlooking.
>>
>> That said, this does seem to work.
>
> Hi Chris,
>
> There isn't any official solution to this, because there are so many
> different though similar use-cases.
>
> I originally started using several approaches and in the end used
> formatted comments in the code to mark the snippets for extraction all
> in one go by a python program run before asciidoc.  That way when
> changing the code you are prompted to change the comments to include
> the right thing.  That said it wasn't production code so nobody minded
> the comments.
>
> But if your method works and is fast enough then just keep using it.
>
> As for empty results, well asciidoc should handle that just fine, I
> don't know if the highlighter will give you an error though.  Still
> you probably want that since having a document saying "here is an
> example of the barred foo" followed by nothing isn't going to look
> good.
>
> Cheers
> Lex
>
>>
>> -Chris
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "asciidoc" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/asciidoc?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "asciidoc" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/asciidoc?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to