How to open a temporary file in a browser with Lua?

105 Views Asked by At

I'm currently working on a plugin for NeoVim in which I parse HTML from the current buffer and write it on a temporary file. Now, I want to open the temporary file in the browser, so it would show the result of the parsed HTML, but I can't get it done.

I have tried using os.execute and finding the path of the file, but it doesn't work.

Currently, my function looks like this. buffer_to_string() returns a string which contains all the content of the current buffer and matching_html() returns the matches between the content and a HTML pattern

function M.preview_html()
  local content = buffer_to_string()
  local matching_html = get_html(content)
  local tmp_file = io.tmpfile()
  tmp_file:write(matching_html)
end
0

There are 0 best solutions below