# HG changeset patch # User HIROSE Yuuji # Date 1505028668 -32373 # Node ID d6952c7e35ccee55b60f0e7fce5acc639c4b2446 # Parent 025522852e1d998db1e06e00c38849216ec3194c Add-in completion for "meta" element now supports charset attribute. diff -r 025522852e1d -r d6952c7e35cc docs/htmlqa --- a/docs/htmlqa Sun Sep 10 16:28:12 2017 +0859 +++ b/docs/htmlqa Sun Sep 10 16:30:41 2017 +0859 @@ -52,6 +52,9 @@ ・を 認識して漢字コードを設定して欲しいなー。 + HTML5 で書くのであればこの構文を使うのはやめ、文字集合はUTF-8に + 絞り と記しましょう。 + 文書の中にファイルのエンコード法を書いてもそもそもそのMETAなんちゃ らを読めない可能性があるので charset をMETAで指定するのは本当に 期待した通りには機能しません。たとえば、多国語文書を書く必要が出 diff -r 025522852e1d -r d6952c7e35cc yahtml.el --- a/yahtml.el Sun Sep 10 16:28:12 2017 +0859 +++ b/yahtml.el Sun Sep 10 16:30:41 2017 +0859 @@ -1,6 +1,6 @@ ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji(@)yatex.org] -;;; Last modified Mon Jul 24 11:03:07 2017 on firestorm +;;; Last modified Sun Sep 10 15:57:47 2017 on firestorm ;;; $Id$ (defconst yahtml-revision-number "1.79.3" @@ -1174,7 +1174,9 @@ ("rel" . yahtml-link-types-alist) ("type" . yahtml-content-types-alist) ("codetype" . yahtml-content-types-alist) - ("http-equiv" ("Refresh")))) + ("http-equiv" ("Refresh") ("Content-Language") ("Content-Type")) + ("charset" + ("utf-8")("euc-jp")("iso-2022-jp")("iso-8859-1")("shift_jis")))) (defvar yahtml-link-types-alist '(("alternate") ("stylesheet") ("start") ("next") ("prev") @@ -1620,27 +1622,29 @@ (read-from-minibuffer-with-history "href: " "" yahtml-url-completion-map))))))) -(defvar yahtml:meta-names - '(("name" ("keywords")("author")("copyright")("date")("GENERATOR")))) +(defvar yahtml:meta-attrs + '(("charset" value) + ("name" content ("keywords")("author")("copyright")("date")("GENERATOR")) + ("http-equiv" content))) (defun yahtml:meta () - (let ((name (yahtml-make-optional-argument - "name" - (yahtml-read-parameter "name" nil yahtml:meta-names))) - http-equiv content) - (if (string= "" name) - (if (string-match - "Content-type" - (setq http-equiv (yahtml-make-optional-argument - "http-equiv" - (yahtml-read-parameter "http-equiv" nil)))) - (error "It's very bad idea to set Content-type in META. %s" - "See docs/qanda") - (concat http-equiv - (yahtml-make-optional-argument - "content" (yahtml-read-parameter "content")))) + (let ((attr (completing-read-with-history + "Meta Attribute: " yahtml:meta-attrs)) + (case-fold-search t) + (completion-ignore-case t) + todonext name http-equiv content) + (cond + ((string= "" attr) nil) + ((and (setq todonext (cdr-safe (assoc attr yahtml:meta-attrs))) + (eq 'value (car todonext))) + (yahtml-make-optional-argument attr (yahtml-read-parameter attr))) + ((eq 'content (car todonext)) + (setq name (if (cdr todonext) + (completing-read-with-history + (format "%s: " attr) (cdr todonext)) + (yahtml-read-parameter attr))) (concat - name + (yahtml-make-optional-argument attr name) (yahtml-make-optional-argument "content" (cond @@ -1657,7 +1661,14 @@ (if (string-match "yahtml" content) (message "Thank you!")) content) - (t (read-string-with-history (concat name ": "))))))))) + ((string-match "content-type" name) + (if (string-match "http-equiv" attr ) + (error "Use