#!/usr/bin/sed # # Prepend a TOC # Print an extra first heading # Delete from 'On this page...' to the *first* first heading # BEWARE the non-breaking spaces! # /On this page.../{ i [[_TOC_]]\n }; /# 1.\s\+/ {s/1.\s\+// p} /On this page/,/^#\+ \w/d /javascript:toggle/d / #toc/d s/^\(#\+\)\s\+[0-9.]\+\s\+/\1 / /?action=edit/d # group . to slash in links /markferry.net\/pmwiki\/pmwiki/ s%n=\(.*\)\.\(.*\)%n=\1/\2%g # strip pmwiki part /markferry.net\/pmwiki\/pmwiki/ s%http://markferry.net/pmwiki/pmwiki.php?n=%/% # strip dead links /\?/ s/\[\(\w\+\)\]\[[0-9]*\]\[?\]\[[0-9]*\]/\1/g s/\[\([^]]\+\)]\[[0-9]\+]\[?]\[[0-9]\+]/\1/g # Convert page titles 1 { i --- s/^#\+\s\+/title: / a --- } # Convert bash code /^#!\/.*sh/,/Get Code/ { /^#!\/.*sh/ i ```shell s/\s\+$// # clean whitespace /Get Code/ { a ``` d } } # Convert ruby code /^#!\/.*ruby/,/Get Code/ { /^#!\/.*ruby/ i ```ruby s/\s\+$// # clean whitespace /Get Code/ { a ``` d } } # Convert ruby code /^#!\/.*python/,/Get Code/ { /^#!\/.*python/ i ```python s/\s\+$// # clean whitespace /Get Code/ { a ``` d } } # House.WhaleBarn has a linked embedded image /(!\[Floor Plan\]\[38\])\[38\]/ { y/()/[]/ s/38/37/g } /^ \[\]: http:\/\/markferry.net\/house\/whale-barn-floor-plan.jpg/ s/\[\]/\[37\]/