Yannick Gingras wrote:
[...]
>   There are many light weight markup languages out there.  One of then
>   it [Markdown][1].  It is popular in web application where is enables
>   users to do basic formating without giving them the full power of
>   HTML, which could lead to security problems.  An alternative is
>   [AsciiDoc][2], a markup just as readable but with a lot more bangs
>   and whistles; AsciiDoc offers the full semantic power of DocBook
>   without the ugliness of XML.
> 
>   [1]: http://daringfireball.net/projects/markdown/
>   [2]: http://www.methods.co.nz/asciidoc/
> 
> As you can see, the named links prevent awkward line breaks in the
> prose block.  Is there a way to do the same with AsciiDoc?
> 

I've been thinking about this and it strikes that attributes (almost)
fit the bill:

This works now:

:a: http://www.methods.co.nz/asciidoc/
:b: http://hg.sharesource.org/asciidoc/

See the {a}[AsciiDoc Home page] and the {b}[AsciiDoc Mercurial
repository].

Using numbered attribute names is nice for references but requires a
change to the `attributeentry-pattern` to allow numeric digits in
AttributeEntry names:
   attributeentry-pattern=^:(?P<attrname>[a-zA-Z0-9].*?):(?P<attrvalue>.*)$

Which then allows:

:1: http://www.methods.co.nz/asciidoc/
:2: http://hg.sharesource.org/asciidoc/
:3: link:downloads.html#X3

See the {1}[AsciiDoc Home page] and the {2}[AsciiDoc Mercurial
repository]. More {3}[information on the Mercurial repository].

This approach inherits all the attribute features, for example passing
values in on the command-line:

   $ asciidoc -a 1=http://x.y.z/ ../tmp/test.txt

Using attributes doesn't add any new concepts or new syntax, the only
problem is the single pass requirement that the attributes are defined
before being used.

OK, so what's the problem with having to define attributes before use?
I guess it's mostly because it's not what we're used to, we expect
references to appear at the end of documents -- but this situation is
a little different because the definitions don't appear in the output
document so the end user won't see them.  If the list is long and it
really bugs you then you can always include them from a separate file 
(also handy for sharing references across multiple documents):

include::references.txt[]

The reference {4}[precedes the caption] but after a few minutes this 
seemed quite normal.

The more I think about it the more I think the restriction of
pre-definition is not really bad, it's just different.

One other point: because same-named positional macro arguments are
only used during macro substitution there shouldn't be a name clash
problem (though this needs to be double-checked).


--
Stuart Rackham
_______________________________________________
asciidoc-discuss mailing list
[email protected]
http://lists.metaperl.com/cgi-bin/mailman/listinfo/asciidoc-discuss

Reply via email to