In my first post (well, second if you consider the intro) I included some php code I wanted highlighted. That shouldn't be so difficult, considering the handy
highlight_string php function. The problem is that blogspot.com doesn't allow you to run actual php code in the post, for well understandable reasons. Solution: run the command on another server, then paste the results. I hacked up a quick page that does just that. It's not standards-compliant, not nice, but gets the job done. Linked to in the title. It first shows a textarea where you paste the code, then submit it. What you get is pure HTML (ok, and a bit of CSS), which you can include in your posts. Here's the script, highlighted by itself:
<html>
<head></head>
<body>
<?php if(!$_POST['code']): ?>
<form method="post" action="highlight.php">
<label for="code">Code to highlight:<br /></label>
<textarea name="code" id="code" cols="90" rows="30" ></textarea>
<br />
<input type="submit" />
</form>
<?php else: ?>
<div class="php_code">
<?php highlight_string($_POST['code']); ?>
</div>
<?php endif ?>
</body>
No comments:
Post a Comment