On 19 June 2013 12:47, Lex Trotman <[email protected]> wrote: > > > > On 19 June 2013 12:38, Dan Allen <[email protected]> wrote: > >> I agree that using a block for this purpose is not in the spirit of the >> design of AsciiDoc. >> > > If I read it correctly (just glanced) Atlas solves this by being a > pre-processor so it can use non-asciidoc syntax. Thats the solution I > ended up using for a customer. Extractors that run as filters must of > course obey Asciidoc syntax. > > >> >> Personally, I think this feature should be baked into the native AsciiDoc >> processor (as it is in Asciidoctor). It's as essential to writers as a >> sidebar, admonition, or anything else. >> > > Agree a built-in source: macro like you say in your previous post would be > good. >
Though I might warn that repeatedly scanning a large and complex code base each time the macro occurs can end up being very slow, which was the other reason to go to the pre-processor method, search the codebase once and find the snippets then substitute them in the asciidoc in one pass. Maybe allowing for picking the snippets from a dictionary populated by a pre-pass of the codebase would be an optimisation. Cheers Lex > > Cheers > Lex > > >> >> >> -Dan >> >> >> On Tue, Jun 18, 2013 at 8:35 PM, Dan Allen <[email protected]> wrote: >> >>> This problem has been solved for AsciiDoc (perhaps not in the spirit of >>> AsciiDoc, but it works). >>> >>> http://codeextactor.berlios.de/codeextractor.html >>> >>> This is such an important feature for technical writers, that I've >>> included a way to do this natively in Asciidoctor. Right now, it's part of >>> the include macro. You can either line lines: >>> >>> include::{sourcesdir}/Example.java[lines=1..10;5..20;40..-1] >>> >>> (that's lines 1-10, 5-20 and 40 to the end) >>> >>> Or tags: >>> >>> include::{sourcesdir}Example.java[tags=example1] >>> >>> >>> I'm also planning on having a source macro that behaves like include, >>> except it wraps the included text in a source listing. >>> >>> source::{sourcesdir}/Example.java[tags=example1] >>> >>> (the source language can be picked from the extension, other attributes >>> can be specified in the normal way). >>> >>> -Dan >>> >>> >>> >>> On Tue, Jun 18, 2013 at 12:17 AM, Harry Percival < >>> [email protected]> wrote: >>> >>>> Another alternative might be dexy: >>>> >>>> http://www.dexy.it/ >>>> >>>> It would have to work as a layer on top of asciidoc, so you'd write >>>> dexy templates to generate asciidoc, which in turn would generate your >>>> final doc. that may be too much complexity for you, but dexy did look very >>>> powerful when i looked at it a few months back... >>>> >>>> hp >>>> >>>> >>>> On 18 June 2013 02:36, Eduardo Santana <[email protected]> wrote: >>>> >>>>> How Atlas does it: >>>>> >>>>> http://chimera.labs.oreilly.com/books/1230000000065/ch04.html#code_snippets_section >>>>> >>>>> Em segunda-feira, 11 de abril de 2011 02h21min24s UTC-3, Stuart >>>>> Rackham escreveu: >>>>>> >>>>>> On 09/03/11 06:58, Anders Nawroth wrote: >>>>>> > Hi! >>>>>> > >>>>>> > I wonder how I could integrate something along the lines of >>>>>> codeextractor into >>>>>> > asciidoc. I'd really like the inclusion of code snippets to be >>>>>> handled inside >>>>>> > the asciidoc execution, and not by pre-parsing the files before >>>>>> running asciidoc. >>>>>> > >>>>>> > Right now I'm using a syntax similar to this one: >>>>>> > >>>>>> > ["snippet", source="Source.java", tag="tag1"] >>>>>> > ---- >>>>>> > ---- >>>>>> > >>>>>> > What annoys me is the empty block, but I couldn't get it to work >>>>>> without it. Any >>>>>> > ideas how this could be done in a better way? >>>>>> > >>>>>> > I'd prefer a syntax close to the include:: macro, but couldn't find >>>>>> out if/how >>>>>> > that could be done. >>>>>> >>>>>> AsciiDoc filters are designed to filter paragraph or block elements, >>>>>> unfortunately macros don't have the ability to execute filter code. >>>>>> >>>>>> Cheers, Stuart >>>>>> >>>>>> >>>>>> > >>>>>> > >>>>>> > /anders >>>>>> > >>>>>> > >>>>>> > 2010-12-23 14:01, Ed Keith skrev: >>>>>> >> --- On Thu, 12/23/10, wimalopaan<wilhel...@fh-**kl.de> wrote: >>>>>> >> >>>>>> >>> From: wimalopaan<wilhel...@fh-**kl.de> >>>>>> >>> Subject: Extracting code snippets from source files and include >>>>>> them >>>>>> >>> To: "asciidoc"<asci...@**googlegroups.com> >>>>>> >>> Date: Thursday, December 23, 2010, 12:39 AM >>>>>> >>> Hi, >>>>>> >>> >>>>>> >>> is there a possibiliy to extract code snippets from >>>>>> >>> external source >>>>>> >>> files and include them in asciidoc documents - perhaps like >>>>>> >>> the boost >>>>>> >>> quickbook snippets? >>>>>> >>> >>>>>> >>> The following source file >>>>>> >>> ------- >>>>>> >>> #include<iostream> >>>>>> >>> //[main >>>>>> >>> int main() { >>>>>> >>> } >>>>>> >>> //] >>>>>> >>> ------- >>>>>> >>> >>>>>> >>> imported in quickbook and selection of the snippet [main] >>>>>> >>> will only >>>>>> >>> render the function main (with the special comments >>>>>> >>> removed). >>>>>> >>> >>>>>> >>> Any hints? Thanks! >>>>>> >>> >>>>>> >> >>>>>> >> I wrote a tool to do this. It can be found at >>>>>> >> https://developer.berlios.de/**projects/codeextactor/<https://developer.berlios.de/projects/codeextactor/> >>>>>> >> >>>>>> >> Hope it helps, >>>>>> >> >>>>>> >> -EdK >>>>>> >> >>>>>> >> Ed Keith >>>>>> >> [email protected] >>>>>> >> >>>>>> >> Blog: edkeith.blogspot.com >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> > >>>>>> >>>>>> -- >>>>> 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. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> ------------------------------ >>>> Harry J.W. Percival >>>> ------------------------------ >>>> Twitter: @hjwp >>>> Mobile: +44 (0) 78877 02511 >>>> Skype: harry.percival >>>> >>>> -- >>>> 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. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Dan Allen | http://google.com/profiles/dan.j.allen >>> >> >> >> >> -- >> Dan Allen | http://google.com/profiles/dan.j.allen >> >> -- >> 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. >> >> >> > > -- 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.
