The riddle of the NetNewsWire visited link
- Posted
21 June 2025
Past me is a fool. He spent a portion of my limited lifetime supply of keypresses on the colour choice of visited links in a NetNewsWire theme.
In case you haven’t caught on (I forgive us), NetNewsWire is not a browser. It displays some HTML in a web view. This content, extracted from an XML file, usually includes links. Links are <a>
elements with a :visited
state. Logical right? Not quite. It didn’t cross the code-addled mind of past me that NetNewsWire never visits web pages. How do you get a visited link without the visit!
The thing is… I was seeing visited links in NetNewsWire. I was styling visited links. Definitely visited. In the colour I assigned to a:visited
. In the theme I had installed. But how? What is going on?
To avoid unnecessary embarrassment I won’t mention some of the (fortunately shallow) irrational rabbit holes I looked in first. The important clue was where the visited links were appearing. Only in some feeds, and only adorning the feed link title.
This is the bit where I plug the Template variable NetNewsWire theme. Necessary because NetNewsWire does not have dev tools enabled in it’s web view (I remember the web before Firebug – it was not pretty). Anyway…
Turns out, the feeds displaying the :visited feed link title. Did not have a feed link.
Of course there was a link! I can see it. If I click it, my browser opens the blog post on the web. That is confusing. I know. I was confused too, for a moment at least. I’ll try to explain because when I understood I laughed.
This is the pertinent portion of template before NetNewsWire renders the page:
<a href="[[feed_link]]">[[feed_link_title]]</a>
NetNewsWire, to render a feed item, replaces tokens in the template. A feed item with no feed link might result in this perfectly valid link.
<a href="">A curiously visited link</a>
Here it is rendered in this page: A curiously visited link. Give it a click. You’ll find it reloads the page, because it is a link to the current page.
Which of course you’ve visited. As a matter of fact, you’re there right now.
But, but, that’s not what happens when I click the “visited” links in NetNewsWire. It loads the feed item’s page on the web, past me might have said.
This is explained by the presence of a base tag in the template in which the link is rendered.
The base URL to be used throughout the document for relative URLs.
NetNewsWire assigns the feed item’s “preferred link” to this URL. As a result, empty links, relative to the base link, effectively become the base link. That is, a link to the blog post NetNewsWire has rendered.
Scratch theme update
Now I know what’s going on, I’ll change Scratch to display feed items in feeds lacking feed links a little differently.
Despite the empty link kinda working, it is at very least surprising. If a feed doesn’t have a feed link, I reckon it makes more sense to display the feed title unlinked. If anything it is redundant alongside the title with the same link.
To apply this logic without relying on JavaScript, I’ve applied a similar trick already used in the theme template to handle missing titles. Repeating the feed title in a span displayed in place of the link when the href
is empty.
<a href="[[feed_link]]">[[feed_link_title]]</a><span>[[feed_link_title]]</span>
The CSS:
header a + span,
header a[href=""] {
display: none;
}
header a[href=""] + span {
display: inline;
}
While I was at it I ensured <object>
tags scaled like video; And, of course, deleted the visited colour.
Install
To enable a quick switch between different versions of this theme I’ve generated a zip of each version – incorporating the version number in the name:
Get the latest version on the Scratch project page.
Next up
I’ve been side tracked by a baseline grid, taking advantage of text-box. Not sure where it is going yet.