4 ms·
>Getting author information a.k.a. byline relies primarily on either on the correct appearance two attribute=value pairs rel=author or itemprop=author, or a reg
by Arnavion 5y ago
>Getting author information a.k.a. byline relies primarily on either on the correct appearance two attribute=value pairs rel=author or itemprop=author, or a regexp soup matching potential byline matches.
The heuristics are indeed brittle, which is why I had to add:
<span class="work-around-firefox-reader-mode-bug" rel="author"></span>
... to my website. Without that, Reader Mode would look for the first HTML element that contained the string "author", assume its content was the name of the author of the article, and make it a byline right below the title. Of course the element it picked was a section header, with the content "Completing an authorization". So not only did I end up with a blog post written by "Completing an authorization", but also the section that was supposed to have that header no longer had a header.
So the hack is to add another element before the website content that it picks instead. is a ZWNJ, which I used because Reader Mode is too smart for its own good and will ignore an element that has empty text content or just an NBSP. So a ZWNJ is the next-best thing.
But it's great when it works, and I'm glad it exists. I have JS disabled by default and have lost count of the number of websites that use CSS to hide their content and JS to make it visible. Reader Mode defeats them easily.
- deleted 5y ago[deleted]
- emsixteen 5y agoWhy use a ZWNJ and not just, well, an actual author name? I'm probably missing something here.
- Arnavion 5y agoBecause it's my website and I get to decide whether to have an author name or not. It's bad enough that browsers assume my website, that's made up entirely of free-flowing text inside p tags, won't fit on phone screens unless I add a meta viewport tag. I'm not going to also make changes to the content to satisfy them.
- account42 5y ago> It's bad enough that browsers assume my website, that's made up entirely of free-flowing text inside p tags, won't fit on phone screens unless I add a meta viewport tag. This anoys me to no end as well. It's especially ridiculous now that mobile browsers provide a "Desktop" mode that can be used as a fallback for those sites that do need a larger page width.
- jerf 5y ago" is a ZWNJ, which I used because Reader Mode is too smart for its own good and will ignore an element that has empty text content or just an NBSP." ZWNJ and its other zero-width friends is my ninja secret. Oh, are you demanding this text box be filled with something? No thank you. Have a ZWNJ. Few, if any, sites that are "checking" for content being in some widget "correctly" filter out the entire Unicode space class. (I mean, I assume somewhere out there there is one, but so far this has never failed me.) Most of them just filter out ASCII space 32. A few are smart enough to filter out tabs as well; if Reader is also filtering out NBSP that already puts it at the head of the class. I'm not sure I've yet encountered one that is filtering out the entire Unicode class. (On the other hand, I would submit that by the time someone has taken the time to find one and copy & paste it into your text widget, you should consider your options carefully. The user has just demonstrated significant technical sophistication. It may not be your wisest move to also filter that out. You want some Zalgo emojis? Because I can give you Zalgo emojis. You may not want Zalgo emojis; there are still some systems out there that emojis can break. You want to find out?)
- progforlyfe 5y agoInteresting bug. I bet they'd be willing to accept a PR to tweak that logic that searches for "author".. or i hope they would. For example by looking within word boundaries (\b)
- pmoriarty 5y ago"Without that, Reader Mode would look for the first HTML element that contained the string "author", assume its content was the name of the author of the article, and make it a byline right below the title. Of course the element it picked was a section header, with the content "Completing an authorization"." Why would a section header in your article contain "author" if you didn't mean for it to designate who the author of the article was?
- chimeracoder 5y ago> Why would a section header in your article contain "author" if you didn't mean for it to designate who the author of the article was? It's bad substring matching. It's "authorization", but apparently Firefox just interprets that as "author".
- pmoriarty 5y agoOh, I see. Yeah, that's a bug in the design, because it's trying to infer metadata from unstructured content. There's no reliable way to do it. The right way would be to only use explicitly defined metadata and if it's not there to default to showing nothing.
- chimeracoder 5y agoPresumably there is a class="authorization" or something like that in the enclosing element, so it's not that they're inferring metadata from unstructured content - it's that they're drawing bad inferences from the metadata provided. That said, inferring metadata from unstructured content is literally the whole goal of Reader mode - to make pages more readable even if the original source didn't design it to be - so while this particular bug is avoidable, others may not be.
- pmoriarty 5y ago"inferring metadata from unstructured content is literally the whole goal of Reader mode" Is that the whole goal, or is it to get around the design choices of the original? These are two different things.