Attribute references

Michel Fortin michel.fortin at michelf.com
Sun Jan 9 16:19:06 EST 2005


Le 9 janv. 2005, à 13:19, John Gruber a écrit :

> The similarity to link references is, hopefully, obvious. I'm
> thinking there would *only* be this reference-style syntax, with no
> provision for assigning tag attributes inline in the article text
> itself. (If you want to do that, just use real HTML tags.)

The similarity is obvious, but I believe this is a really bad way to 
assign the id attribute. More on this later.

> One advantage of this is that for something like classes, you can
> define one class attribute defintion, and reuse it on as many
> elements as you need.

A class is already something you define at one place and reuse later. 
Because of this I tend to use small class names which are ideal when 
you refer to them often. I see no use in having to define another small 
name that will be a reference to the class name. I see this as a 
reference to a reference.

> One disadvantage is that you could do the same thing with id's,
> which of course would produce invalid HTML if the same `id` value is
> used on more than one element per page. I think we'll just have to
> trust the user to know what they're doing here -- if you don't know
> the rules of HTML, it's unlikely you'd ever use this anyway.

Ids, just like classes are already some sort of references, but refer 
to some part of the document. Lets look at this document using your 
syntax:

	## My Intriguing Header ## {intrigue}

	{intrigue}: id="intrigue"

	This is a link to [my intriguing header](#intrigue).

Can you tell me what the attribute reference try to accomplish here? I 
think it's a lot better this way:

	## My Intriguing Header ## {id="intrigue"}

	This is a link to [my intriguing header](#intrigue).

Or this way:

	## My Intriguing Header ## {#intrigue}

	This is a link to [my intriguing header](#intrigue).

* * *

If you don't mind, my proposition for a syntax would be like this. In 
the curly brackets, I would allow a list of attributes, ids identified 
by a leading hash (`#`), and classes identified by a leading dot (`.`). 
So this thing:

	![image](sourceURL){#my-image .my-class width="30" height="30"}

... would produce this:

	<img src="sourceURL" alt="image" id="my-image"
	class="my-class" width="30" height="30" />

Of course you can choose to assign an id using `{id="my-id"}`. The hash 
syntax and the dot syntax for classes is only a shortcut.

> So to assign an attribute reference to a list:
>
>     * This
>     * That
>     * The other
>
>     {foo}
>
>     Now back to regular text.

This is exactly as I thought: just require that one empty line stands 
between the block element and the attribute assignment.

If the line was to be interpreted as a paragraph, it would be an empty 
paragraph with some attributes, which does not make much sense. I think 
this should be allowed with any block-level element, header and 
paragraphs included, for consistency.

Using my syntax, you can also do this:

	> There have been a lot of good feature ideas for Markdown
	> discussed on the Markdown-Discuss mailing list. Among the
	> features I’d like to add for version 1.1:
	>
	> *   A way to specify a `cite` attribute for blockquotes.

	{cite="http://daringfireball.net/2004/12/markdown_licensing"}


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/


More information about the Markdown-Discuss mailing list