From Markdown to .odt and vice-versa
29 May 2016I wanto to convert complex documents for Markdown so they can be used here to write this blog. There are lots of ways, but i choose the following one.
We need to have LibreOffice, pandoc, and a text editor.
The process is this.
-
Create a .odt file in LibreOffice, using the following. The first three items in the list must be applied using styles, i.e. from “Styles and Formatting” > “Paragraph Styles”:
- Headings—not Titles,
- Preformatted Text (only works for block elements),
- Quotations,
- ordered and unordered lists,
- hyperlinks,
- italics and bold,
- footnotes.
- Run
pandoc -s file.odt -t markdown -o file.md
- Edit the markdown file.md and correct every thing that seems wrong!!! There is some markdown editors, i like to use MarkdownPad2.
Test:
Here is a heading
Here is some text. Here is some italics. Here is some bold. Here is a link4. Here is a footnote.1
Here is some text. Here is some italics. Here is some bold. Here is a link4. Here is a footnote.2
Here is some text. Here is some italics. Here is some bold. Here is a link4. Here is a footnote.3
Here is a subheading
Here is a subsubheading
Here is a subsubsubheading
- Here is an unordered list.
- Here is an unordered list.
- Here is an unordered list.
Here is some text. Here is some italics. Here is some bold. Here is a link4. Here is a footnote.4
- Here is an ordered list.
- Here is an ordered list.
- Here is an ordered list.
Here is some monospace text.
Here is a blockquote. Here is a blockquote.
Pandoc
Pandoc is a general markup converter that can convert from one markup format to another. It can read Markdown, CommonMark, PHP Markdown Extra, GitHub-Flavored Markdown, and (subsets of) Textile, reStructuredText, HTML, LaTeX),MediaWiki markup, TWiki markup, Haddock markup, OPML, Emacs Org mode, DocBook, txt2tags), EPUB, ODT and Word docx;
and it can write plain text, Markdown, CommonMark, PHP Markdown Extra, GitHub-Flavored Markdown, reStructuredText, XHTML, HTML5, LaTeX (including beamer slide shows), ConTeXt, RTF, OPML, DocBook, OpenDocument, ODT, Word docx, GNU Texinfo, MediaWiki markup, DokuWiki markup), Haddock markup, EPUB (v2 or v3), FictionBook2, Textile, groff man pages, Emacs Org mode, AsciiDoc, InDesign ICML, TEI Simple, and Slidy, Slideous, DZSlides, reveal.js or S5 HTML slide shows. It can also produce PDF output on systems where LaTeX, ConTeXt, or wkhtmltopdf is installed.
Using Pandoc
By default, pandoc produces a document fragment, not a standalone document with a proper header and footer. To produce a standalone document, use the -s or –standalone flag:
To convert from markdown to Word docx:
pandoc -s -S input.md -o output.docx
To convert from Word docx to markdown:
pandoc -f docx -t markdown foo.docx -o foo.markdown
To convert markdown to PDF:
pandoc input.md -o output.pdf
To convert from .odt to markdown:
pandoc -s file.odt -t markdown -o file.md
To convert from markdown to .ODT (OpenDocument Text):
pandoc input.md -o output.odt
See: *http://pandoc.org/demos.html
References
- https://writers.stackexchange.com/questions/9056/from-markdown-to-odt-and-vice-versa-a-possible-
- distraction-free-writing-workfl
- http://extensions.libreoffice.org/extension-center/texmaths-1
- http://extensions.libreoffice.org/extension-center/writer2latex-1
- https://discourse.suttacentral.net/t/converting-from-word-processor-to-markdown/21
- Markdown instead of Word Processors