LoginSignup
2
2

More than 5 years have passed since last update.

cygwin で 日本語 markdown を textile に変換してクリップボードにコピーする

Last updated at Posted at 2017-01-17

TL; DR

  • pandoc, nkf をインストールして、下記のようにパイプでつなげる
  • clip コマンドは Shift-JIS じゃないと文字化けするので nkf -s を挟むといい感じになる
  • /dev/clipboard を使う方法もあるが、cat にパイプする or 一度ファイルに出力する、といった一手間が必要になる
$ pandoc -s -S markdown-file.md -t textile | nkf -s | clip

※ nkf を使わない方法
$ pandoc -s -S markdown-file.md -t textile | cat > /dev/clipboard

※ 一度ファイルに出力してからクリップボードにコピーする方法
$ pandoc -s -S markdown-file.md -t textile -o output.textile
$ output.textile > /dev/clipboard

サンプル

$ cat test.md
# 見出し
- hoge
- fuga

# 見出し
## 見出し2
- hoge
    - hogehoge
- hoge
    - hogehoge

## 見出し2
- hoge

$ pandoc -s -S test.md -t textile | nkf -s | clip

※ クリップボードにコピーされたデータ
h1(#見出し). 見出し

* hoge
* fuga

h1(#見出し-1). 見出し

h2(#見出し2). 見出し2

* hoge
** hogehoge
* hoge
** hogehoge

h2(#見出し2-1). 見出し2

* hoge

動作確認環境

$ pandoc -v
pandoc.exe 1.19.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, highlighting-kate 0.6.3
Default user data directory: C:\Users\user-name\AppData\Roaming\pandoc
Copyright (C) 2006-2016 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

$ nkf -v
Network Kanji Filter Version 2.1.4 (2015-12-12)
Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).
Copyright (C) 1996-2015, The nkf Project.

$ which clip
/cygdrive/c/WINDOWS/system32/clip

所感

  • 普段 markdown でメモとってて、社内の Redmine に投稿する時に便利

EOF

2
2
4

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
2
2