Last active
April 17, 2021 17:05
-
-
Save vivit-jc/f0cb1f13ab0b3262904e1ec152301db0 to your computer and use it in GitHub Desktop.
テスト用カード整形スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# csvのみ対応 | |
# 第1引数にファイル名、第2引数に出力ファイル名 | |
# カラム1.枚数 | |
# カラム2.名前 | |
# カラム3.テキスト | |
# カラム4.属性(あれば)#未実装 | |
header = <<'EOS' | |
<!DOCTYPE html> | |
<head> | |
<style> | |
td{ | |
width: 150px; | |
height: 188px; | |
padding-left: 10px; | |
} | |
span.name{ | |
font-size: 120%; | |
font-weight: bold; | |
} | |
span.small{ | |
display: block; | |
font-size: 80%; | |
line-height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<table border="1"> | |
EOS | |
str = "" | |
cards = [] | |
count = 0 | |
File.open(ARGV[0],"r") do |f| | |
f.each_line do |l| | |
cards << l.strip.split(",") | |
end | |
end | |
str += "<tr>\n" | |
cards.each do |c| | |
c[0].to_i.times do |i| | |
str += "</tr><tr>\n" if count%4 == 0 && count != 0 | |
if(c[2].size > 40) | |
str += "<td valign=top><span class=\"name\">"+c[1]+"<\/span><span class=\"small\"><br>"+c[2].gsub("br","<br>")+"<\/span><\/td>\n" | |
else | |
str += "<td valign=top><span class=\"name\">"+c[1]+"<\/span><br>"+c[2].gsub("br","<br>")+"<\/td>\n" | |
end | |
count += 1 | |
end | |
end | |
footer = <<'EOS' | |
</tr> | |
</table> | |
</body> | |
</html> | |
EOS | |
File.open(ARGV[1],"w") do |f| | |
f.puts header+str+footer | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment