Format Code Inside PRE Tags within TextMate Using PHP
Creating blog posts has been greatly sped up by the use of TextMate. I've created a bunch of blog formatting commands to do various operations on posts including adding paragraph tags, formatting headings, and generating content based on string templates. One of my favorites is a PHP function that html-entitizes (your word of the day) code with PRE tags.
The PHP
function replace_angles($matches) {
return str_replace($matches[1],htmlentities($matches[1]),$matches[0]);
}
$file = file_get_contents('php://stdin');
$file = preg_replace_callback('/<pre.*?>(.*?)<\/pre>/imsu',replace_angles, $file);
echo $file;
The first step is reading in the buffer's contents. The next step is using PHP to extract the PRE code and replace it with htmlentities(code). Mission accomplished! I use this frequently within my blog -- maybe you can too.
CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?
Remember the Web 1.0 days where you had to customize your site in every way possible? You abused the scrollbars in Internet Explorer, of course, but the most popular external service I can remember was CometCursor. CometCursor let you create and use loads of custom cursors for...
Google recently introduced an interesting effect to their homepage: the top left and top right navigation items don't display until you move your mouse or leave the search term box. Why? I can only speculate that they want their homepage as...
Have you looked into using markdown in textmate instead? It’s already got a lot of what you’re talking about :D
hello Sir,
I would like to ask u some question. I tried to use htmlentities like that
htmlentities('hello', ENT_QUOTES);
but it is not working. (also htmlspecialchars ) I would like to know how to do this problem.