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.

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36