6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pandocで文書のマークダウン形式を変換する

Last updated at Posted at 2016-06-04

やりたいこと

  • kobitoで書いてqiitaに投稿したmarkdown形式のテキストを、mediawikiになるべく簡単に転載したい。
  • リンク先URLとして貼るのは嫌。

良い方法はないか模索

pandocとは

  • Pandoc ユーザーズガイド 日本語版より引用

     Pandocは Haskell で書かれたライブラリおよびコマンドラインツールであり、 あるマークアップ形式で書かれた文書を別の形式へ変換するものです。
     
     対応している入力形式は以下の通りです:
     
         markdown
         Textile (のサブセット、以下同様)
         reStructuredText
         HTML
         LaTeX
         MediaWiki markup
         Haddock markup
         OPML
         Emacs Org-mode
         DocBook
     
     出力形式は以下の通りです:
     
         プレーンテキスト
         markdown
         reStructuredText
         XHTML
         HTML 5
         LaTeX (beamerスライドショーを含む)
         ConTeXt
         RTF
         OPML
         DocBook
         OpenDocument
         ODT
         Word docx
         GNU Texinfo
         MediaWiki markup
         EPUB (v2またはv3)
         FictionBook2
         Textile
         groff manページ
         Emacs Org-Mode
         AsciiDoc
         InDesign ICML
         HTMLスライドショー:Slidy、Slideous、DZSlides、reveal.js、S5
         PDF出力(LaTeXがインストールされているシステムで使用できます)
    
    • 「やりたいこと」ができそう!

Pandoc インストール

  • brew経由でpandocをインストール

     $ brew install pandoc
    
  • 確認

     $ pandoc --version
     pandoc 1.14.0.4
     Compiled with texmath 0.8.2, highlighting-kate 0.6.
     Syntax highlighting is supported for the following languages:
         abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c,
         changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css,
         curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd,
         eiffel, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go,
         haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json,
         jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell,
         lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki,
         metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb,
         objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike,
         postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml,
         roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql,
         sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul,
         yacc, yaml, zsh
     Default user data directory: /Users/LowSE01/.pandoc
     Copyright (C) 2006-2015 John MacFarlane
     Web:  http://johnmacfarlane.net/pandoc
     This is free software; see the source for copying conditions.
     There is no warranty, not even for merchantability or fitness
     for a particular purpose.
    

使い方

  • markdown形式のテキストを用意

     $ cat sample.md
     # Pandocで文書のマークダウン形式を自由自在に操る方法
     
     ## やりたいこと
     * kobitoで書いてqiitaに投稿したmarkdown形式のテキストを、mediawikiになるべく簡単に転載したい。
     * リンク先URLとして貼るのは嫌。
     
     ## 良い方法はないか模索
     * [Pandoc を使って Markdown を Mediawiki に変換する方法](http://tatsushid.github.io/blog/2015/01/how-to-convert-markdown-into-mediawiki/) - tatsushid.github.io
    
  • 変換してみる

     $ pandoc -f markdown -t mediawiki ./sample.md
     = Pandocで文書のマークダウン形式を自由自在に操る方法 =
     
     == やりたいこと ==
     
     * kobitoで書いてqiitaに投稿したmarkdown形式のテキストを、mediawikiになるべく簡単に転載したい。
     * リンク先URLとして貼るのは嫌。
     
     == 良い方法はないか模索 ==
     
     * [http://tatsushid.github.io/blog/2015/01/how-to-convert-markdown-into-mediawiki/ Pandoc を使って Markdown を Mediawiki に変換する方法] - tatsushid.github.io
    
  • いい感じっす!

結論

  • しばらく使ってみます!
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?