Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy HTML with CSS to Libre Office

I have an HTML page styled with CSS. I would like to copy it to Libre Office Writer, so that I can edit it. However, when I copy & paste, only the HTML is copied, without the style. I tried "Paste Special - HTML" and got the same results.

I use Libre Office 3.5.3.2 on Ubuntu 12.04.

like image 880
Erel Segal-Halevi Avatar asked Aug 13 '12 07:08

Erel Segal-Halevi


People also ask

Can LibreOffice open HTML files?

To make LibreOffice open your default web browser and display the contents of an HTML document, go to File > Preview in Web Browser on the Menu bar, or click the Preview in Web Browser icon on the Standard toolbar. You can also open any web browser and then open the HTML file in it.

Does LibreOffice support HTML?

LibreOffice Writer can create, edit, and save web pages in HTML format using a configuration called Writer/Web.

How do you copy style in LibreOffice?

Show the style “navigator” with F11 or Styles > Styles & Formatting . In the small toolbar, there is an icon with a down pointing arrow in rightmost position. Click on it and select Load Styles . In the dialog, check all style families and Overwrite so that identically named styles are replaced.


1 Answers

It seems that the style of <body> is discarded and only inline CSS is used when you copy and paste. For me, copying from Firefox and pasting in LibreOffice, the following HTML didn't retain formatting:

<head>
  <style type="text/css">
    body { font-family: sans-serif; font-size: 15px; }
    span { color: red; }
  </style>
</head>
<body>
  Lorem ipsum <span>dolor</span> sit amet.
</body>

and

<body style="font-family: sans-serif; font-size: 15px;">
  Lorem ipsum dolor sit amet.
</body>

But the following worked as expected:

<body>
  <div style="font-family: sans-serif; font-size: 15px;">
    Lorem ipsum <span style="color: red;" >dolor</span> sit amet.
  </div>
</body>
like image 132
Marco Avatar answered Oct 21 '22 00:10

Marco