EOL
2023-08-29
dejbug.github.ioEOL
In the currentiteration
the next two weeksblog.py for a proper lexer gh.
First I'll need to define and freeze the input format
the markdown flavor of my bloglocal
context-lessTag it and bag it
The word foot-note reminds me of the little yellow plastic tags that mortuaries probably keep boxes of.Boxes among trees
So there is a display property called "contents" drafts.csswg.org drafts.csswg.org which I didn't know about. Serves to show that I really need to forget everyting I thought I knew 20 years ago and re-learn the stuff. Well, someday. Nobody is paying me to be a front-end dev. So for now I'll learn the stuff on a need-to-know basis.Pushing up the daisies
A couple of things to look at:inline floats
dev:moz:target
dev:moz:popover-open
dev:moz:local-link
dev:moz:host
dev:moz::slotted()
( dev:moz::part()
dev:moz::marker
dev:mozThe details element is not appropriate for footnotes. html.spec:w3I've abused the details element a little. dev:moz For the new lexer I should be looking at
<dfn>
dev:moz<dt>
dev:mozDead Parrot
The examples in html.spec:w3 show great taste and erudition on the part of the technical writers at Mozilla. I must say!Firefox in Firefox
This is the uri:chrome://browser/content/browser.xhtml . It was linked from the developer tools console (<C-S-j>).
Digressions
I made the mistake of looking at a page and then wondering whether it had syndication and then looking at itsrss.xml and then thinking "Wait a second...!" why didn't I write an addon yet to reformat the xml into a rss reader-like affair?
De-Atomizer (temporary name)
Or Union Buster! or Scab! (as in de-syndicator) or Unionice? (as in syndication niceifier)... Basically you load an xml file that happens to be an RSS or Atom feed and this Web Extension will make it humanly readable. If it recognizes the feed's source it will apply stylesheets that match the source's corporate identity. Everything went smoothly, since you could just build upon the very first example Mozilla gives you, which is a content script that adds a border. But the progress came to a full stop when I realized that there is no intuitive way to set the document'scontentType.
The problem is, once you've surfed to an XML page the window.document will point to an XMLDocument instance. Now window.document is a read-only property so you can't just window.document = new HTMLDocument() and document.contentType is readonly too.
There used to be a two-argument version of "document.open()" that could do it. I found that out almost by chance while scouring the docs. There's no alternative given on that sorry excuse for a proper reference page. You can't even click your way from "api.method" back to "api". So, again by chance, I stumbled upon something that reminded me of a thing I never used before except for SVGs: createElementNS(). Note the ominous "NS".
Regex
Experimentation turned out that if you remove all elements from the XMLDocument and add some elements created with an explicit namespace infra.spec:w3 it will all print as it would in an HTMLDocument. So this is a way to do it by hand. Just regex through the XML and then replace it with html-namespaced elements.XSLT
The more elegant butXSLT (two days later)
I am writing these words two days later. I have just now found the solution to a problem so frustrating that it made me scream. And yes it has to do with XSLT. I don't want to look at this pile of rubbish any longer than I have to but well, now that I see the logic in it, I just might revise that sentiment once I've thoroughly calmed down. It's been 20 years since last I had been dealing with this stuff. My hovercraft is full of eels.The Problem
I was trying to parse an RDF-style RSS. web.resource.org The freakingxmlns="...rss..." tripped me up. It made all the tags that weren't explicitly prefixed with a shorthand (e.g. dc:creator) fall into this anonymous namespace. So there was no way to select the nodes just by their names.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns="http://purl.org/rss/1.0/"
>
<item><title>...</title></item>
<item><title>...</title></item>
</rdf:RDF>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="RDF">
Found the root?
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:template match="rdf:RDF">
Found the root!
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:value-of select="/rdf:RDF/channel/title"/>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
>
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:value-of select="/rdf:RDF/channel/title"/>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="/*/*">
<xsl:value-of select="name(.)"/><xsl:text>:
</xsl:text>
<xsl:for-each select="*">
<xsl:text> </xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="namespace-uri(.)"/>
<xsl:text>)
</xsl:text>
</xsl:for-each>
</xsl:template>
namespace-uri() that I had to have to excavate the root cause of my suffering. Because it reconfirmed that it was indeed a namespace issue and not one of the many other things that were coming to mind. I found it while looking through the list of XPath functions here w3. I've been looking for anything that could reveal the hidden structure behind a simple name like title.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://purl.org/rss/1.0/"
>
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title"/>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://purl.org/rss/1.0/"
>
<xsl:output method="text" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="//rss:item">
<xsl:value-of select="rss:title"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
Black Adder
I'm listening to something called "SoundTV Dub Techno Mix (NASA Special 2)" ( yt? ) on Radio Schizoid's Dub channel schizoid. Before I had to spend two hours in XML maze I was trying to replicate GitHub Doc's TOC. I find it nice how the current subtopic is highlighted as you scroll through the page. I've seen this before in other places but never really thought about it much. There are a couple near-misses here. There'sposition: sticky dev:moz. There's :target dev:moz. Real solutions start with getBoundingClientRect dev:moz. But you'll find something much dearer to the heart called the Intersection Observer API dev:moz.
Currently I'm using it to toggle some classes on and off on h3 elements as they're scrolling in and out of view. After each event I find the first header in the scrolled-into-view class and take the one before it to be the sticky header. All is working well so far. I'm showing the current topic in a little overhead strip as if position: sticky were used on the header but nicer.
There is a nasty edge-case here where the previous title overlays the current title as it scrolls into view, but the rootMargin option solves this nicely.