Re: XML reformating

From: phayz <russelldicken....at.gmail.com>
Date: Wed, 2 Jun 2010 20:32:29 -0700 (PDT)

On Jun 3, 4:50 am, "briancsch....at.gmail.com" <briancsch....at.gmail.com>
wrote:
> Here's a function for re-formatting XML. Requires some sort of echo
> command and HTML tidy to be installed and placed on your system's
> PATH. Not tested on anything but Linux.
>
> local function reformat()
>         local tidyString = 'tidy -i -xml -q -w '..buffer.edge_column
>                 ..'  --indent-spaces '..buffer.indent..' --tab-size
> '..buffer.tab_width
>         local text = buffer:get_text():gsub('"', '\\"')
>         local p = io.popen('echo "'..text..'" | '..tidyString..' 2>&1')
>         local out = p:read('*all')
>         p:close()
>         if buffer.use_tabs then
>                 out = out:gsub(string.rep(" ", buffer.indent), "\t")
>         end
>         buffer:set_text(out)
> end

Brian,

This looks great! I'll try it under Windows and report the results
here.

Regards,
Received on Wed 02 Jun 2010 - 23:32:29 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:46:52 EST