The more I think about the overlay code
I mentioned in my previous post the more I
want it. But the actual implementation doesn't seem sufficient to
me... it's very vague that when ids simply overlap they get merged,
and there's no way to indicate an id you mean to be merged and one you
want to use for some other purpose. Also, the overlay itself can't
pull in external resources, which I want. And lastly, while
expressions might not be necessary, I think some form of cascading is
good. For instance, if you have an <h1> element that you want to
take either the document title or something by the id html-title
(which can contain markup), there should be a way to express that.
Now that I think about it, there should also be a way to merge the
head elements entirely, probably with some knowledge of the
semantics of HTML (like one <title> element).
So, here's an idea:
- <link rel="overlay" type="text/x-name-of-this-spec" href="...">
enables this. Plus, perhaps, some Javascript in the head (if you
aren't doing server-side resolution). That javascript should look
like <script src="..." type="text/javascript"
overlay="1"></script>, and any server-side processor will strip
that out.
- In the overlay, you can use an attribute slot="id1 id2 ...".
This will fill the slow with the content of id1, or id2 if id1 is
not present. If no id is present, the content will be left in-tact.
- In the overlay [or other content?] you can have
include="uri#fragment". This includes the given URI. If a
fragment is given, then the content of the element by id is
included, and the rest is thrown away. [Should the content of the
head be kept/merged? Should there be other things besides simple id
matching to include bits, like XPath or somesuch?]
- The contents of <head> are merged. <meta> tags that match
(i.e., the http-equiv or name attribute match) are removed.
Duplicate titles are removed. I think that's all I care about. The
first document (the one that links to the overlay) gets priority,
then the overlay, then included content (if included content's head
stuff is included at all). Other content, like scripts and styles
and links, are all thrown together in the head from all sources.
I think that's it. Damn, that shouldn't be hard to implement. But I
must keep myself from implementing it, because I'm really trying to
get the last few loose ends together for a Paste 0.4 release.
Must... stop... self...
The one pain in the ass part of this is parsing HTML. Easy in
Javascript, but not in Python. With parsed markup, this is
super-easy to implement.