« Movable Type 3.34 Upgrade | Main | AdSense and JavaScript »

Text formatting MT Plugins

I just installed a set of MT plugins which I hope will make it easier to post entries in general, and code samples in particular.

The plugins are MT-Textile, SmartyPants and MTCodeBeautifier.

Respectively they should let me format my entries, use proper quote characters, and format code samples.

The installs are pretty basic, just copy the files or directories as specified in the install instructions. I also added some CSS to my stylesheet to support MTCodeBeautifier. The CSS changes support the syntax highlighting and also set up code blocks to have scroll bars if needed.

The rest of this post will just test out these plugins. I just noticed that MT-Textile added a "Textile 2" text formating option for my entires. I'll try that out and also use some text formatting. Already in previewing this post I can see that SmartyPants is being used to quote Textile 2 properly.

This paragraph has some text formating tests. Here's strong text. This is emphasis text. This is bold text. This is italic text. There's lots more.

Let's try some character replacements like the © copyright symbol, the ¢ cent sign, and an ... ellipsis.

  • Here's
  • a
  • simple
  • list.

And finally some code samples.

A simplistic contact form in PHP -

";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "";
}
else{
  print "";
}
?>

Let's try some Perl now:

#!/usr/bin/perl
use DBI;
use strict;
my $user = 'someuser';
my $password = 'somepw';
my $dsn = 'DBI:mysql:cpu_stat:localhost';
my $dbh = DBI->connect($dsn, $user, $password,
                      { RaiseError => 1, AutoCommit => 0 })
   or die "Couldn't connect to database: " . DBI->errstr;
my $insert_cpu =
            $dbh->prepare_cached("INSERT INTO vm_stat VALUES (CURRENT_TIMESTAMP,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

my $vm_stat = `vmstat`;

$vm_stat =~ m/(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/;

$insert_cpu->execute($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
                        or die "Couldn't insert row into cpu_stat table: " . DBI->errstr;

$insert_cpu->finish();
$dbh->disconnect();

That's all for now. One thing I like is that I can choose what sort of text formatting to use on each entry. That's nice. I can leave my old entries alone and use Textile 2 whenever I need it.


© 2016 Mike Silversides

About

This page contains a single entry from the blog posted on March 9, 2007 12:08 PM.

The previous post in this blog was Movable Type 3.34 Upgrade.

The next post in this blog is AdSense and JavaScript.

Many more can be found on the main index page or by looking through the archives.