Tested on OpenBSD 6.3 and 6.4
rssg is an RSS feed generator written in shell. It’s a good companion for ssg.
It gets feed’s description, URL, and the list of items from an index file.
Then for every item it extracts its title and treats the rest of the file as its description, replacing all relative URLs with absolute ones.
An index file can be in HTML or in Markdown format.
Finally, rssg outputs the feed in XML format.
148 LoC. grep and sed everything
Download and chmod it:
$ ftp -Vo bin/rssg https://www.romanzolotarev.com/bin/rssg rssg 100% |*********************| 4137 00:00 $ chmod +x bin/rssg $ doas pkg_add lowdown quirks-2.414 signed on 2018-03-28T14:24:37Z lowdown-0.3.1: ok $
$ rssg index.html 'title' > rss.xml $
Here is an example of a minimal index.html
file:
<h1>People who run BSD</h1> <p> Stories written by users of BSD operating systems. Hosted by Roman Zolotarev. </p> <p> Subscribe via <a href="https://runbsd.info/people/rss.xml">RSS</a>. </p> <ul> <li><a href="mischapeters.html" title="2018-08-07">Mischa Peters</a></li> <li><a href="h3artbl33d.html" title="2018-08-06">h3artbl33d</a></li> </ul>
HTML parsing rules:
<H1>
and <A>
tags should not contain line breaks.<H1>
tag.<P>
tag.<H1>
tags are excluded from description.HREF
attribute of the first <A>
tag
with RSS
content.<A>
tags and TITLE
attribute.HREF
attribute of that line, item date is
TITLE
attribute, and item title is the content of <A>
tag.Thanks to Devin Teske for her awk(1) wizardry.