How to paste HTML so that it renders

I’m using code highliter tohtml to create HTML code out of plain text file with a program. When I paste the HTML into LibreOffice Writer or Impress it is pasted as-is, i.e. just the HTML code is shown. The same operation in Google Docs or MS Word works as expected - the HTML if it’s rendered in the browser.

Alternatively, I’d use built-in code highliter, but I couln’t find such a tool. I’m using LibreOffice 4.2.7.2 on Ubuntu 14.04.

Here’s a sample HTML code

<pre style='color:#d1d1d1;background:#000000;'><html><body style='color:#d1d1d1; background:#000000; '><pre>

class Message
def self.haha
puts “haha”
end
end

that should render the following Ruby code

class Message
  def self.haha
    puts "haha"
  end
end

I also tried to wrap the HTML code into HTML5 template, but pasting didn’t succeed.

Valid question, I was just searching how to paste copied html source into libre office. Why was this closed?