Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[convert-to-use-perl] added simple converter

I can write HTML, but I don't want to manually add all the crazy stuff
use.perl forces me to do to make the posts come out right. Better to
let a script do that. This script puts <p>...</p> around comment
paragraphs, and escapes the '<' and '>' characters in code paragraphs.
It also turns all the spaces in the latter into &nbsp; so that when
the user copies and pastes, code doesn't get wrapped.
  • Loading branch information...
commit 4210e0a6348684a29991bf2cc0cc0397ba109bd2 1 parent 2efe4f2
@masak authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 convert-to-use-perl
View
20 convert-to-use-perl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -n
+
+BEGIN { $/ = "\n\n"; };
+
+chomp; chomp;
+
+if (/^>/) {
+ print "<code>";
+ for (split("\n", $_)) {
+ s/ /&nbsp;/g;
+ s/</&lt;/g;
+ s/>/&gt;/g;
+ s/$/<br>\n/;
+ print;
+ }
+ print "</code>\n\n"
+}
+else {
+ print "<p>$_</p>\n\n"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.