2023-09-12 Oddmuse to Oddmu conversion

I had to convert a few thousand pages from my Oddmuse wiki for Oddµ, i.e. Markdown.

Oddmuse

Oddµ

This took me a while to get right…

The current situation is an iterative design. I started out in a working directory with a symlinks for `wiki.pl` because I needed the HTML rendering. I decided I was going to read every page, render it as HTML (unless it was a file upload), and convert that HTML to Markdown. I did this using to-markdown.pl.

to-markdown.pl

Then I realized that I was going to use the modification date of the files for a primitive Recent Changes and I had forgotten to set the `mtime` on the Markdown files – and I had already started modifying a handful of files! This wouldn't do. I fixed this using ts-markdown.pl. Then again, eventually I picked a different solution for Recent Changes.

ts-markdown.pl

a different solution for Recent Changes

From now on it was important to work with `rsync --archive` in order to keep the timestamps!

Later, I added hashtags to Oddµ. I realized that I don't want to write [#tag](/search?q=%23tag) every time I need a tag. I just want to write #tag. Once I had added this to Oddµ, however, I needed to convert all the existing Markdown files and change what `to-markdown.pl` had generated. I fixed this using fix-tags.pl.

fix-tags.pl

At first I tried something using `rpl` but it doesn't do regular expressions. Then I tried something using `grep`, `xargs` and `sed`, but then I needed `find`, and then the commands got longer and longer and I finally decided that this is what Perl is for. And indeed, I was so much faster.

As it turns out, I found yet another oversight. All the comments, which I was sure would end up at the bottom of the various pages, did not make it. Here I am, writing another script to fix that: add-comments.pl.

add-comments.pl

Sadly, I was also left with over 50 comment pages without a page to attach them to! Some of them were comments on uploaded files. Since the uploaded files no longer have a "page" they also can't have comments. So now I'm trying to deal with those comments one by one. What a mess.

​#Oddmuse ​#Oddµ ​#Perl

Mostly to simplify something like this:

[![Alex RPG Logo 2008](https://alexschroeder.ch/pics/Alex RPG Logo 2008.png "Alex RPG Logo 2008")](../pics/Alex%20RPG%20Logo%202008.png)

The goal being something like this:

![Alex RPG Logo 2008](/pics/Alex%20RPG%20Logo%202008.png)

In order to get there, I've been running the following commands and I feel like there are probably still a lot more pages that need fixing.

oddmu replace -confirm '\[!\[\]\(https://alexschroeder.ch/pics/([^\)]+)\)\]\(\.\./pics/[^\)]+\)' '![](/pics/$1)'
oddmu replace -confirm '\[!\[([^\]]+)\]\(https://alexschroeder.ch/pics/([^ \)]+) "[^"]+"\)\]\(\.\./pics/[^\)]+\)' '![$1](/pics/$2)'
oddmu replace -confirm '\]\(\.\./pics/' '](/pics/'
oddmu replace -confirm '\((https://alexschroeder.ch/pics/[^" ]+) ([^" ]+ "[^"]+")\)' '($1%20$2)'
oddmu replace -confirm '\[!\[([^\]]+)\]\(https://alexschroeder.ch/pics/([^\)\"]+) "[^"]+"\)\]\((/pics/[^\)]+)\)' '![$1]($3)'

Names

replace-names.pl

`oddmu missing|wc -l` still reports ~~4193~~ ~~2767~~ ~~1525~~ ~~535~~ ~~274~~ 0 missing links (also fixed a bug that resulted in every missing link twice). It was tough, but I did it!