26

I'm writing a master thesis (Sociology) and I'm really penalized by distractions. I would happily shift to a markdown full-screen environment but I wrote an half of the thesis in .odt via LibreOffice, so I would like to know if it's possible to convert from .odt to Markdown, maintaining the footnotes (which are the most important thing in my work) and also the formatting of the bibliographical notes.

Maybe It could be useful to revert the process and, at the end of the work, go back to .odt file to reformat pages, line height and other things.

Is there a way to do so?

Alternatively, there is a way to write full-screen directly in a .odt file maintaining footnotes (because FocusWriter and TextRoom doesn't have this feature)?

Kropot
  • 361
  • 1
  • 3
  • 3

4 Answers4

29

Your first option is, really, Pandoc, which was already mentioned. Its usage is quite straightforward. I've done some converting along these lines myself, and it's brilliant. It's included in Debian repositories, so I'd think acquiring an installation wouldn't be a problem.

You indeed want to convert to HTML first:

pandoc OdtFile.odt -o HtmlFile.html

and then proceed to create markdown file the same way:

pandoc HtmlFile.html -o MarkDown.text

and yes, you could go back from markdown to odt the same way. You also could enforce your own style set by mentioning style template odt file, the README will tell you, how.

You may also find it useful to preserve paragraphs with the flag --wrap=none - i.e. prevent pandoc breaking pars with newlines every 72 chars.

To prevent odd HTML formatting (such as you get where the original doc has embedded links: pandoc endows those in the output markdown text with underline html tags), specify the markdown version as markdown_github-raw_html with -t markdown_github-raw_html. (Might be preferable to change the source doc's default link formatting in the Office app that created it, if you can).

Another option is to forego markdown for some kind of TeX solution (to which format you also could convert your already written text with Pandoc), the advantages being the abilities to insert images, tables and math equations in text, though, I'm afraid, that will close the way back to odt.

markling
  • 103
  • 3
Undespairable
  • 421
  • 4
  • 8
2

To augment Undespairable's answer, these commands from the command line convert from markdown to HTML and then HTML to ODT.

pandoc .\some-file.md -f markdown -t html -s -o .\some-file.html    

pandoc .\some-file.html -f html -t odt -o .\some-file.odt

See also: https://www.pandoc.org/getting-started.html

Shaun Luttin
  • 121
  • 3
2

I've been playing around with odt2txt. It strips out all formatting, leaving just plain text, perfect for diffs, and an acceptable starting place for doing your markup, and if you combine it with @AnandaMahto's suggestion to use Pandoc to convert it back, I have some ugly papers to try this on.

hildred
  • 2,835
  • 1
  • 17
  • 33
1

Have you looked into WriteMonkey? There doesn't seem to be a plug-in to do what you want, but it is a robust distraction free markdown environment.

If converting to html and then to MD works, this might be the ideal editing environment for you. WriteMonkey will export MD to MS Word, which could then be opened in LibreOffice when you're done.