From 031b8014901bd101d92af148a841e9b9c8fb59f5 Mon Sep 17 00:00:00 2001 From: haturatu Date: Wed, 9 Oct 2024 01:36:19 +0900 Subject: fi --- md.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'md.rb') diff --git a/md.rb b/md.rb index 1a8da2b..24c2eb4 100755 --- a/md.rb +++ b/md.rb @@ -3,7 +3,7 @@ def convert_to_markdown(input_file, output_file) content = File.read(input_file, encoding: 'utf-8') - pairs = content.scan(/URL: (.*?)\nTitle: (.*?)\n/m) + pairs = content.scan(/URL: (.*?)\nタイトル: (.*?)\n/m) File.open(output_file, 'w', encoding: 'utf-8') do |f| pairs.each do |url, title| @@ -14,7 +14,7 @@ def convert_to_markdown(input_file, output_file) title = url.split('/')[-1] if title.strip.empty? # 特殊文字をエスケープ - title = title.gsub('[', '\\[').gsub(']', '\\]') + title = title.gsub(/[\[\]\(\)\{\}]/) { |m| "\\#{m}" } # md形式のリンクを作成 markdown_link = "[#{title}](#{url})\n\n" -- cgit v1.2.3