footnote:id, colons and jquery

David Chambers david.chambers.05 at gmail.com
Wed Jan 23 21:48:03 EST 2013


I sometimes find colons useful. Here's an example:

<li class="c10n-file document ext:pdf">resume.pdf</li>

Using "ext:pdf" rather than "ext-pdf" makes it clearer that this class name
acts as a key–value pair. Sure, I could use `data-extension="pdf"` here
instead, but selector engines are optimized for finding elements by class
name.

In the case of CSS, all that's required is a backslash to escape the colon:

.c10n .c10n-file.document.ext\:pdf {
background-image: url(assets/fugue/document-pdf-text.png);
}

In my view it's fine to include colons in ids, but I'm not strongly opposed
to the *pragmatism not idealism* stance.

David


On 23 January 2013 17:12, Michel Fortin <michel.fortin at michelf.ca> wrote:


> Le 23-janv.-2013 à 14:29, Waylan Limberg <waylan at gmail.com> a écrit :

>

> > I just received a [bug report] for Python-Markdown complaining that

> > colons are used in the ids of footnotes. For reference, we [output]

> > the same format at PHP Markdown Extra. The general complaint is that

> > the colon in the id attribute (`id="fnref:1"`) causes jquery to choke

> > when referencing that id from javascript because jquery uses colons to

> > indicate pseudo elements (as does CSS). As expected, jquery supports

> > escaping the colon - which eliminates the problem - except that

> > apparently the escaping causes a performance hit.

> >

> > My initial reaction is to say that this is jquery's problem, but what

> > do you think? Should the various implementations that support

> > footnotes all change to not use colons? I couldn't help but note that

> > Gruber's unreleased implementation (what he uses on

> > daringfireball.com) appears to use dashes instead.

> >

> > Any thoughts?

>

> Interestingly, I've been looking at updating the output for footnotes in

> PHP Markdown, although not the id attribute.

> <https://github.com/michelf/php-markdown/issues/58>

>

> My guess is that Jquery has an optimization for the common pattern

> "#nocolon" and that putting an escape forces it to take the slow path. Take

> his example and add a class name (making the selector "#nocolon.anyclass"),

> or put an ancestor (as in "body #nocolon") and you'll get equal speed

> everywhere.

>

> --

> Michel Fortin

> michel.fortin at michelf.ca

> http://michelf.ca/

>

> _______________________________________________

> Markdown-Discuss mailing list

> Markdown-Discuss at six.pairlist.net

> http://six.pairlist.net/mailman/listinfo/markdown-discuss

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20130123/da38ac3d/attachment-0001.htm>


More information about the Markdown-Discuss mailing list