7
6

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.

Excel からコピーして Markdown でペースト

Last updated at Posted at 2015-08-11

table_print gem 使ってスクリプト書く。

$ gem install table_print -v "~> 1.5.4"
#!/usr/bin/env ruby
gem "table_print", "~> 1.5.4"
require "table_print"
require "csv"

table = CSV.new(
  $stdin.read,
  col_sep: "\t",
  row_sep: :auto,
  headers: :first_row
).map(&:to_hash)

tp.set :multibyte, true
tp table

tsv2md という名前でパスの通ったところへ保存し、実行権限つける。

Excel や Google Spreadsheet でコピーして下記を実行すると、Qiita などで使える Markdown Extra 記法でクリップボードにコピーされる。

$ pbpaste | tsv2md | pbcopy

ただし、コピーする表の 1 行目は列名にすること。

7
6
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?