LoginSignup
10
11

More than 5 years have passed since last update.

W3CValidatorsがSublimeText3で動かなかったので動くようにした

Posted at

W3CValidatorsとは

【Sublime Text2】W3Cのバリデーションチェックができるパッケージ「W3CValidators」 | バシャログ。

dubharmonic/Sublime-W3CValidators

はじめてのPython

初めて触るPythonだったけど単純なソースだったので直してみることにした。
結果的には主にPython2 -> 3の対応。

公式のリファレンスを参考に。
API Reference - Sublime Text 3 Documentation
Porting Guide - Sublime Text 3 Documentation

あとPython 2 -> 3の以降ガイド。
Python 3 Porting Guide — Porting to Python 3 v1 documentation

変更内容

urllibの仕様変更と、リクエスト送受信時はバイナリでエンコード/デコードしなきゃいけなくなった模様。

参考:
Python 3.x: urllib.request error - Stack Overflow

-    encodedParams = urllib.urlencode(params)
-    output = urllib.urlopen(validatorUrl, encodedParams).read()
+    encodedParams = urllib.parse.urlencode(params)
+    binary_data = encodedParams.encode('utf-8')
+    output = urllib.request.urlopen(validatorUrl, binary_data).read().decode("utf-8")
+    

インストール

以下からダウンロードして手動インストール後、SublimeText3を再起動してください。

ksz/Sublime-W3CValidators

Macの場合
git clone https://github.com/ksz/Sublime-W3CValidators
mv Sublime-W3CValidators ~/Library/Application Support/Sublime Text 3/Packages/
10
11
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
10
11