Thursday 19 February 2009

Notepad2 plugins/addons feature

I am using this feature to reformat HTML or XML source by tidy console application.
File->Launch->Open with... (Alt+L)
Then I have two batch files
tidyuphtml.cmd
c:\...\tidy\tidy.exe -config c:\...\tidy\tidyuphtml.ini %1 %2 %3 %4 %5

tidyuphtml.ini
indent: auto
indent-spaces: 2
wrap: 0
markup: yes
output-html: yes
output-xml: no
input-xml: no
show-warnings: yes
numeric-entities: yes
quote-marks: yes
quote-nbsp: yes
quote-ampersand: no
break-before-br: no
uppercase-tags: no
uppercase-attributes: no
char-encoding: raw
new-inline-tags: option, cfif, cfelse, math, mroot, mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover, munder, mover, mmultiscripts, msup, msub, mtext, mprescripts, mtable, mtr, mtd, mth
new-blocklevel-tags: cfoutput, cfquery
new-empty-tags: cfelse
tidy-mark:no
wrap-attributes:no
write-back:yes


tidyupxml.cmd
c:\...\tidy\tidy.exe -config c:\...\tidy\tidyupxml.ini %1 %2 %3 %4 %5

tidyupxml.ini
char-encoding:raw
indent:yes
indent-spaces:2
input-xml:yes
output-xml:yes
quiet:no
tidy-mark:no
uppercase-attributes:no
uppercase-tags:no
wrap:0
wrap-attributes:no
write-back:yes

While you have your HTML or XML opened in editor press Alt+L and browse to location of *.cmd files. Whether you need to reformat HTML or XML choose your batch file and click OK. Then you will be notified of file modification. Click yes and your file is reformatted (this operation is not undoable and all unsaved changes will be lost)

In Open with... window you can also set your default "plugin" directory.

No comments: