From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Fri, 10 Jan 2014 20:36:52 +0000 Subject: RFE: .so filters In-Reply-To: <52D0572E.7080607@xinu.at> References: <20140109225802.GM7608@serenity.lan> <20140110090639.GN7608@serenity.lan> <52D029F9.40805@xinu.at> <52D0520C.1070609@xinu.at> <20140110201144.GQ7608@serenity.lan> <52D0572E.7080607@xinu.at> Message-ID: <20140110203652.GR7608@serenity.lan> On Fri, Jan 10, 2014 at 09:25:18PM +0100, Florian Pritz wrote: > On 10.01.2014 21:11, John Keeping wrote: > > Forking and using Lua in the child is an interesting idea. > > > > I need to investigate how Lua generally deals with I/O, but it feels > > like it will be simpler to use a simple function interface than deal > > with slurping in the input in Lua. > > Looks rather easy to slurp stdin (from http://www.lua.org/pil/21.1.html): Interesting. But I think it will be simpler from both side if the interface is just a function call: function filter(value) return value .. " some trailing data" end The change on the CGit side is then quite easy, we just change the switchable value in html.c from htmlfd to html_out_fn which has the same signature as html_raw (which is the default implementation). Then we can collect output in a strbuf until it's time to call the function. The only thing I'm not sure about is how the specification of the filter function works, given that I don't think we can call a complete Lua script as a function. (I'm also assuming that the Lua script will be in an external file and not stored inline in the CGit config).