Home     About     Archive     Links

From Markdown to .odt and vice-versa

I 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.

  1. 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.
  2. Run pandoc -s file.odt -t markdown -o file.md
  3. 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

  1. Here is an ordered list.
  2. Here is an ordered list.
  3. 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.

http://pandoc.org/README.html

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

  1. Here is a footnote. 

  2. Here is a footnote. 

  3. Here is a footnote. 

  4. Here is a footnote. 

GitHub Pages now faster and simpler!

Updates to Markdown filter and syntax highlighters

Github recently adopted Kramdown as their only Markdown processor, which will go into effect after May 1.

And instead of Pygments, Rouge will be now the only syntax highlighter supported by Github Pages. Github announced these changes in a recent blog post:

GitHub Pages now only supports Rouge, a pure-Ruby syntax highlighter, meaning you no longer need to install Python and Pygments to preview your site locally. If you were previously using Pygments for highlighting, the two libraries are feature compatible, so we’ll swap Rouge in for Pygments when we build your site, to ensure a seamless transition.

Traditionally, highlighting in Jekyll has been implemented via the { % highlight % } Liquid tag, forcing you to leave a pure-Markdown experience. With kramdown and Rouge as the new defaults, syntax highlighting on GitHub Pages should work like you’d expect it to work anywhere else on GitHub, with native support for backtick-style fenced code blocks right within the Markdown.

You can create fenced code blocks by placing triple backticks ``` before and after the code block.

How to make the updates to use Kramdown and Rouge

If you were using redcarpet and Pygments, and you want to switch to Kramdown and Rouge, you need to make an update in your configuration file. For example, if you previously had this:

highlighter: pygments
markdown: redcarpet
redcarpet:

extensions: [“no_intra_emphasis”, “fenced_code_blocks”, “tables”, “with_toc_data”]

Just change it to this:

highlighter: rouge
markdown: kramdown
kramdown:

input: GFM
auto_ids: true
syntax_highlighter: rouge

Make sure you specify the Github Flavored Markdown parser by adding input: GFM. Otherwise backticks won’t be processed.

Test

{ % highlight css % }
body {
margin: 0;
}
{ % endhighlight % }

Output:

   
  body {   
   margin: 0;   
  }    

```css
body {

  • margin: 0;*
    }
    ```

Output:

body {      
 margin: 0;      
}

References

What's Jekyll?

Jekyll is a static site generator, an open-source tool for creating simple yet powerful websites of all shapes and sizes. From the project’s readme:

Jekyll is a simple, blog aware, static site generator. It takes a template directory […] and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.

It’s an immensely useful tool and one we encourage you to use here with Hyde.

Find out more by visiting the project on GitHub.

Welcome to Jekyll!

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the _posts directory that follows the convention YYYY-MM-DD-name-of-post.ext and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

Jekyll also offers powerful support for code snippets:

Ruby syntax

def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.

Github fenced code blocks

def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.

Kramdown tildes

def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.

Check out the Jekyll docs for more info on how to get the most out of Jekyll. File all bugs/feature requests at Jekyll’s GitHub repo. If you have questions, you can ask them on Jekyll Talk.

References