LoginSignup
1
1

More than 3 years have passed since last update.

a タグを Markdown 記法に変換する Python スクリプトを作った

Posted at

a タグを Markdown 記法に変換する Python スクリプトを作った

HTML の a タグを手で Markdown 記法にいちいち変換していたら負けている気がしてきたので作った.

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import fileinput
import re
import sys

pattern = re.compile('<a href="([^"]+)">([^<]+)</a>')

for line in fileinput.input():
    sys.stdout.write(pattern.sub(r'[\2](\1)', line))
1
1
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
1
1