HTMLサニタイズ

これまでLinux TipsのHTMLサニタイズは秀丸でやってたのだが、sedのスクリプトで

sed -e 's/\&/\&/g' \
    -e 's/</\&lt;/g' -e 's/>/\&gt;/g' \
    -e 's/"/\&quot;/g' \
    -e 's/  /\&nbsp;\&nbsp;/g' \
    -e 's/\(# .*\)/<SPAN class="Comment">\1<\/SPAN>/g' \
    -e 's/$/<BR>/g' \
    -e 's/^$/<BR>/g'

~/bin/html_san.sh というフィルタを作ったよ、という備忘録。f(^^;;