yatex

changeset 475:d6952c7e35cc dev

Add-in completion for "meta" element now supports charset attribute.
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 10 Sep 2017 16:30:41 +0859
parents 025522852e1d
children 50351656cb6b
files docs/htmlqa yahtml.el
diffstat 2 files changed, 35 insertions(+), 21 deletions(-) [+]
line diff
     1.1 --- a/docs/htmlqa	Sun Sep 10 16:28:12 2017 +0859
     1.2 +++ b/docs/htmlqa	Sun Sep 10 16:30:41 2017 +0859
     1.3 @@ -52,6 +52,9 @@
     1.4  ・<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=x-sjis">を
     1.5    認識して漢字コードを設定して欲しいなー。
     1.6  	
     1.7 +	HTML5 で書くのであればこの構文を使うのはやめ、文字集合はUTF-8に
     1.8 +	絞り <meta charset="utf--8"> と記しましょう。
     1.9 +	
    1.10  	文書の中にファイルのエンコード法を書いてもそもそもそのMETAなんちゃ
    1.11  	らを読めない可能性があるので charset をMETAで指定するのは本当に
    1.12  	期待した通りには機能しません。たとえば、多国語文書を書く必要が出
     2.1 --- a/yahtml.el	Sun Sep 10 16:28:12 2017 +0859
     2.2 +++ b/yahtml.el	Sun Sep 10 16:30:41 2017 +0859
     2.3 @@ -1,6 +1,6 @@
     2.4  ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*-
     2.5  ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji(@)yatex.org]
     2.6 -;;; Last modified Mon Jul 24 11:03:07 2017 on firestorm
     2.7 +;;; Last modified Sun Sep 10 15:57:47 2017 on firestorm
     2.8  ;;; $Id$
     2.9  
    2.10  (defconst yahtml-revision-number "1.79.3"
    2.11 @@ -1174,7 +1174,9 @@
    2.12      ("rel" . yahtml-link-types-alist)
    2.13      ("type" . yahtml-content-types-alist)
    2.14      ("codetype" . yahtml-content-types-alist)
    2.15 -    ("http-equiv" ("Refresh"))))
    2.16 +    ("http-equiv" ("Refresh") ("Content-Language") ("Content-Type"))
    2.17 +    ("charset"
    2.18 +     ("utf-8")("euc-jp")("iso-2022-jp")("iso-8859-1")("shift_jis"))))
    2.19  
    2.20  (defvar yahtml-link-types-alist 
    2.21    '(("alternate") ("stylesheet") ("start") ("next") ("prev")
    2.22 @@ -1620,27 +1622,29 @@
    2.23  	(read-from-minibuffer-with-history
    2.24  	 "href: " "" yahtml-url-completion-map)))))))
    2.25  
    2.26 -(defvar yahtml:meta-names
    2.27 -  '(("name" ("keywords")("author")("copyright")("date")("GENERATOR"))))
    2.28 +(defvar yahtml:meta-attrs
    2.29 +  '(("charset" value)
    2.30 +    ("name" content ("keywords")("author")("copyright")("date")("GENERATOR"))
    2.31 +    ("http-equiv" content)))
    2.32  
    2.33  (defun yahtml:meta ()
    2.34 -  (let ((name (yahtml-make-optional-argument
    2.35 -	       "name"
    2.36 -	       (yahtml-read-parameter "name" nil yahtml:meta-names)))
    2.37 -	http-equiv content)
    2.38 -    (if (string= "" name)
    2.39 -	(if (string-match
    2.40 -	     "Content-type"
    2.41 -	     (setq http-equiv (yahtml-make-optional-argument
    2.42 -			       "http-equiv"
    2.43 -			       (yahtml-read-parameter "http-equiv" nil))))
    2.44 -	    (error "It's very bad idea to set Content-type in META.  %s"
    2.45 -		     "See docs/qanda")
    2.46 -	  (concat http-equiv
    2.47 -		  (yahtml-make-optional-argument
    2.48 -		   "content" (yahtml-read-parameter "content"))))
    2.49 +  (let ((attr (completing-read-with-history
    2.50 +	       "Meta Attribute: " yahtml:meta-attrs))
    2.51 +	(case-fold-search t)
    2.52 +	(completion-ignore-case t)
    2.53 +	todonext name http-equiv content)
    2.54 +    (cond
    2.55 +     ((string= "" attr) nil)
    2.56 +     ((and (setq todonext (cdr-safe (assoc attr yahtml:meta-attrs)))
    2.57 +	   (eq 'value (car todonext)))
    2.58 +      (yahtml-make-optional-argument attr (yahtml-read-parameter attr)))
    2.59 +     ((eq 'content (car todonext))
    2.60 +      (setq name (if (cdr todonext)
    2.61 +		     (completing-read-with-history
    2.62 +		      (format "%s: " attr) (cdr todonext))
    2.63 +		   (yahtml-read-parameter attr)))
    2.64        (concat
    2.65 -       name
    2.66 +       (yahtml-make-optional-argument attr name)
    2.67         (yahtml-make-optional-argument
    2.68  	"content"
    2.69  	(cond
    2.70 @@ -1657,7 +1661,14 @@
    2.71  	  (if (string-match "yahtml" content)
    2.72  	      (message "Thank you!"))
    2.73  	  content)
    2.74 -	 (t (read-string-with-history (concat name ": ")))))))))
    2.75 +	 ((string-match "content-type" name)
    2.76 +	  (if (string-match "http-equiv" attr )
    2.77 +	      (error "Use <meta charset=\"...\" instead..  See docs/qanda.")
    2.78 +	    (yahtml-make-optional-argument
    2.79 +	     "content" (yahtml-read-parameter "content"))))
    2.80 +	 (t (read-string-with-history (concat name ": ")))))))
    2.81 +     (t (yahtml-make-optional-argument
    2.82 +	 attr (yahtml-read-parameter attr))))))
    2.83  
    2.84  (defun yahtml:br ()
    2.85    (yahtml-make-optional-argument "clear" (yahtml-read-parameter "clear")))