A few more thoughts on plinks
From the comments on my plinks entry, it seems some people are seeing ugly green hash marks all over the place. If that includes you, you need to force-reload my stylesheet to ensure you are getting the copy with the plink hiding styles.
One of the things I missed in last night’s 1am coding frenzy was the idea of globally unique identifiers for every paragraph, as described by Chris Dent. This leads in to a fascinating concept called Transclusion, which originated with Ted Nelson (the father of hypertext) and involves content that is managed by reference.
Now interesting though Transclusion is I’m not convinced that it’s a useful addition to my blog. However, there is a far more pressing need for globally unique paragraph idenfifiers that has only just cropped up: my index page. On it, I display a number of different entries at once. IDs in XHTML must be unique for the current document, so if I have two entries on the front page that contain paragraphs with clashing identifiers I lose validity and, most probably, God kills a kitten.
There are two ways of solving this. Firstly, I could give every paragraph on the site a globally unique identifier—something Chris calls a Node ID. That doesn’t really tempt me: it’s quite a bit of work, and as I’m not currently interested in Transclusion (although maybe I should be) I don’t gain anything from it other than a valid index page. The second alternative is the one I’ve gone for: I’m simply stripping all paragraph IDs from the entries when they are displayed on the front page of the site (and for the entries-by-day views as well). It’s a little hackish and it means my CMS is now doing a bit of lifting when previously it was blissfully unaware of the numbers, but at least it solves the problem at hand. I kind of like the ID of the addressable paragraphs only existing on the “official” entry page in any case.
Here’s the PHP I use to strip out the IDs:
$entrytext = preg_replace('/<p id="p-[^"]+"/', "<p", $entrytext);
One of the many benefits of writing software for yourself is that you can often take huge liberties: I know for a fact that this naive regular expression (as opposed to a more resilient technique using an XML tool of some sort) will work on all 1420 entries on this site because, well, I wrote them all.
Anne - 30th May 2004 22:36 - #
Though it may require a tricky combination of server-side code and javascript depending on the exact results you are seeking, but if you're up to it, make each paragraph on the front page have a link to itself on the archive page.
For example, you may want to try using classes:
<p class="p-3">Blah blah blah. <!-- JS-generated link --> <a href="archive/page#p-3">#</a></p>Lenny Domnitser - 30th May 2004 23:59 - #
Simon Willison - 31st May 2004 00:03 - #
I find the effect too subtle to be noticed. For ages I could not see any plinks at all. I was expecting the whole paragraph to change background colour.
Also, Opera 7.50 does not show them as links.
Chris Hester - 31st May 2004 00:20 - #
I have been thinking about this for some time. I really like the Transclusion, as it provides a universal means to identify, link to, and quote direct, or near direct text (the next step would add the verse).
I like the javascript approach, but ultimately I would like to have PHP add these elements. I am also thinking of implementing my permalink identifier and the paragraph, that way the entry can be parsed along with the paragraph number. Things do get out of whack when edits are made, unless they are entered as updates after the last paragraph.
What I have been playing with would be <p id="1244p7">. This is the 1244th entry and paragraph 7.
The use of CSS is brilliant in this manner as it make it easy, once one knows to look for the faint grey hash. This would make things relatively easy to add and not interfere with the visual reading of the text.
vanderwal - 31st May 2004 03:12 - #
Vanderwal, that's a nice though, but it needs amending somewhat. IDs cannot begin with numbers.
<p id="e1244p7">perhaps.Lach - 31st May 2004 03:54 - #
Lenny Domnitser - 31st May 2004 05:18 - #
Simon Willison - 31st May 2004 05:42 - #
Wesley Mason - 31st May 2004 09:09 - #
CpILL - 31st May 2004 15:53 - #
There is indeed value for having each content-structure (headings, lists as well as paragraphs) addressable. Indeed I'm convinced enough that the next cms-type system should have this feature - although something with friendlier link names. Joe Clark is on to something with his basic-esque line number increments, but I'd prefer a system based around friendly identifiers for headings, tables, lists, and friendly + line numbers for paragraphs, table cells (co-ordinates?) and list items.
I'm not convinced about the approach to displaying these identifiers. You mention your dislike of other approaches as being too website dependant - I can agree. Your solution is an improvement in that regard - hidden until needed.
Although I think a better solution may be to make the javascript parts of the functionality as a bookmarklet. This has the advantage of one bookmark being usable on sites other than your own. A bookmarklet that works on incution.com will also automatically work on Joe Clark's material.
As I understand it, fragment identifiers are done as an id attribute in any element in XHTML, and using the name attribute on anchors in HTML. A bookmarklet that "enabled"/"disabled" the display of fragment identifiers would be useful.
Do you see any drawbacks with that idea? I guess the one downer is that sites require something obvious to indicate the presence of fragment identifiers. I hesitate to suggest the use of a small icon - partly because of the backlash against the orange XML icon.
The second drawback I am aware of is the id attribute is heavily used to create hooks into markup for CSS, not particularly for identifying document fragments.
Isofarro - 31st May 2004 18:22 - #
Simon Willison - 31st May 2004 18:29 - #
Jonathan Snook - 31st May 2004 19:43 - #
s.oteric - 1st June 2004 11:47 - #
Michael Day - 2nd June 2004 01:28 - #
Alex - 2nd June 2004 10:59 - #
Kathryn Cramer - 3rd June 2004 00:36 - #