QZ qz thoughts
a blog from Eli the Bearded
Page 3 of 146

Usenet post filter


Okay, I have added a lot more old reviews and along the way wrote a Usenet post to qzpostfilt markup language filter. I call it qznewsfilt .

It does much but not all of the grunt work of conversions. I still have to manually add filenames, tags, fix line wrapped underscore-for-italics issues, convert quotes to blockquotes (where I mean quotes from books and the like, not quotes from other posts), excise quotes from other posts (that context isn't valid on the web), and fix link text.

For the last one, I found many, but not all, could be fixed with a vi macro. I created it using the handy q marcro recorder in vim.

k:.s,[^(]*,_&_ ,^M0Djf"p

A paragon of clarity, isn't it? Broken down:

k                         move up a line
 :.s                      search and replace on current line
    ,[^(]*,               everything up to first open parens
          ,_&_ ,          surround that string now with underscores and end space
                ^M        this is a literal newline to trigger the :s
                  0       move cursor to start of line
                   D      delete to end of line
                    j     move down a line
                     f"   find first " on the line
                       p  paste in last deleted fragment

I used it to turn:

Movie Name
.a https://imdb.example/url/ "at IMDB"

into


.a https://imdb.example/url/ "_Movie Name_ at IMDB"

On the less frequent

Movie Name (Year)
.a https://imdb.example/url/ "at IMDB"

examples, it needed a little bit of white space fixing afterwards.


.a https://imdb.example/url/ "_Movie Name _ (Year)at IMDB"

but overall, not too bad.