1

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
  • os.execute should work fine. `os.execute("xdg-open test.html")` on Linux and `os.execute("start test.html")` (untested) on Windows was my example. What have you tried? – Luke100000 Jul 11 '22 at 09:35
  • Thanks for your help! Finally, due it was a small HTML file, I used what was answered here https://stackoverflow.com/questions/41310742/how-to-start-browser-with-html-string-with-lua – Nicolas Massardo Jul 12 '22 at 04:06

0 Answers0