6

I trying to convert this html

<p><font color = \"#808080\">SHILPI</p>

to docx using pandoc with this command

pandoc -s -o "test.docx" -t html5 -t docx html_file

But its losing colors, I am getting only text, as far as I know I think html code is correct because when I am using wkhtmltopdf to convert same html to pdf it gives the proper color. What can be the issue ? Thanks in advance.

Shilpi Agrawal
  • 595
  • 3
  • 11
  • 26
  • 1
    You question is a duplicate of [pandoc convert html with style sheet to docx](http://stackoverflow.com/questions/29483060/pandoc-convert-html-with-style-sheet-to-docx/29484938#comment53356815_29484938) but I cannot get the solution to work. Therefore I don't think it is fair to link to solution that doesn't work. – Black Frog Sep 24 '15 at 10:23

3 Answers3

12

That's not how Pandoc works, it doesn't understand CSS, only HTML/Markdown. It preserves the content, but not the layout etc, see semantic HTML.

You can, however, use templates to style your output consistently. With Word it's a bit more complicated but you can use the --reference-doc option for mostly the same effect.

mb21
  • 34,845
  • 8
  • 116
  • 142
4

Try:

pandoc  -s -S test.htm -o test.docx

Reference: http://pandoc.org/demos.html

Frank Boucher
  • 1,834
  • 20
  • 25
0

This inspection highlights deprecated HTML tags and provides ability to replace them with CSS or with other tags for some of them. Maybe better use this: <p style="color: #808080">SHILPI</p>

  • 1
    No this is wrong html input its not even working in webpage. – Shilpi Agrawal Sep 24 '15 at 08:13
  • if i not mistake, this a good example for learn all current notations http://www.freecodecamp.com/challenges/bonfire-search-and-replace –  Sep 24 '15 at 09:16