Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding Python Code in a Word Document? [closed]

I am writing a manual using Word / LibreOffice's Writer.

As part of the manual, I'd like to include python code snippets. Naturally, I want these to be included in a nice way.

How can I paste python code into Word / LibreOffice's Writer while keeping its nice format?

like image 705
user3262424 Avatar asked Apr 14 '26 15:04

user3262424


1 Answers

Libre Office should be able to import HTML code. You can use any Highlighter that can output HTML highlighted code. You may try an online highlighter like http://www.tohtml.com/python/ for example.

Edit: Somehow Libre Office is missing HTML code in the Paste Special menu, but here is some trick to get html into the document:

  1. save your html code to a html file
  2. open the html file with libre office (select web page as format)
  3. select everything and hit copy
  4. paste into the document you want it to be in

This is cumbersome, but I didn't find another way, though I can remember, that there was a HTML option in the Paste Special menu in Open Office. May be there is some plugin or similar stuff to do it easier.

like image 129
Christian Goltz Avatar answered Apr 16 '26 17:04

Christian Goltz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!