News/2012/08

2024-05-17 23:39 UTC

Xac Update

Created 2012-08-31
Last Modified 2012-08-31 02:02 UTC
Archive Link https://xyne.dev/news/2012/08

News Feed Plugin

The news feed plugin’s archiving code has been updated to immediately archive all entries for the sake of providing permanent links. Each entry now also includes a table of creation and modification times, along with the aforementioned archive link.

Edit

Of course, after posting this I quickly noticed that the archive links depend on the header identifiers generated by Pandoc. To avoid duplicate identifiers, Pandoc numbers identical headers after the first, from the top. Previously generate archive links can thus change with the addition of new entries, thereby breaking older links.

Until I come up with a better solution, I have removed the fragment identifier from the link.

Xac Update

Created 2012-08-03
Last Modified 2012-08-03 11:56 UTC
Archive Link https://xyne.dev/news/2012/08

Preformatted XHTML In Atom Feeds

The Atom feed generator that I wrote for Xac uses Python’s xml.dom modules. The advantage of these modules is that they are simple to use and included in the default Python libraries. Unfortunately, even after many years, they still have problems with proper parsing and formatting. The crux of the problem is that newlines and white space are incorrectly converted to text nodes when reading XML and unwanted whitespace tends to sneak into the output when pretty-printing the objects. In some cases this may be negligible but not when preformatted text is involved. As seen in a previous post, this resulted in mangled code blocks in the Atom feed itself.

I finally sat down and hacked together a quick workaround. Just for the sake of inserting code, the solution kludge that I ended up with was to insert temporary hash tags for the preformatted blocks that I want to preserve, and then swap them out when the XML is stringified:

## Nasty hack to preserve HTML formatting.
def __str__(self):
  s = toxml(self.doc, self.pretty)
  for e in self.entry_items:
    for k, v in e.pre_blocks.items():
      s = s.replace(k, v, 1)
  return s

This is the same method that I use to pass chunks of plugin input through Pandoc, so the hashing function was already available in Xac.common.

The real solution would be to switch to a better XML library, but so far it just has not been worth the investment of time.

Uncommented

Created 2012-08-01
Last Modified 2012-08-03 11:55 UTC
Archive Link https://xyne.dev/news/2012/08

No More Spambox

The comment form was an underwhelming failure. It worked as intended, but the rate of spam was higher than I had expected. Oh well.

Contact
echo xyne.archlinux.org | sed 's/\./@/'
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0