Using UltraEdit macro to format the HTML when bloging.

Links: http://www.dbatools.net/experience/format-html-with-ultraedit.html

    When posting scripts or query result to blog (Many DBAs have personal blogs), I always use an UltraEdit macro to format it, it will give us good text align. The macro defination is very simple, first step is to replace some HTML reserved char, second step is to replace some space with "&nbsp;", the last step is to replace the line end with "<br />".

    On WordPress blog platform, there is good plugin to format the code, however this plugin does not work when generate the RSS item feed. Let's start a SQL demo to explain this question.

SELECT /*+ FULL(T) */
  REAGION_ID, COUNT(*)
  FROM SALES
  GROUP BY REGION_ID;

    Create a macro in UltraEdit with the following instructions.

InsertMode
ColumnModeOff
HexOff
UnixReOn
TabsToSpaces
Find "&"
Replace All "&amp;"
Find ">"
Replace All "&gt;"
Find "<"
Replace All "&lt;"
Find "  "
Replace All "&nbsp; "
Find "^p"
Replace All "<br />^p"

    If you format the SQL with this macro, you already see the output above, however if you do not format it, it looks like following.

SELECT /*+ FULL(T) */ REAGION_ID, COUNT(*) FROM SALES GROUP BY REGION_ID;

    I have been using this macro for more than 2 years.

Comments (1)

Hey... I'm having a bit of problem with the way your site is displaying. For some reason the text block is running into the border. I don't know if it's just me or are others reporting the same thing? Just wanted to let you know in case you've been making changes. Thanks! Carmelo Trumbley

Post a comment

Remember Me?

« Previous | Main | Next »

Powered by
Movable Type 5.01