From: MORIOKA Tomohiko Date: Wed, 17 Mar 2010 19:16:02 +0000 (+0900) Subject: (www-uri-decode-char): Expect char-rep to be encoded as URI. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90bbce1c07115156afb38bfcb8060979fa94e80f;p=chise%2Fest.git (www-uri-decode-char): Expect char-rep to be encoded as URI. (www-uri-encode-char): Encode UCS characters as %XX encoding. (www-format-feature-name-as-CCS): Insert space between prefix (..., ===>, ==>, =>, =>>, =>>>, ..., =) and main-name. (www-html-display-text): Don't escape "&" except ">-". --- diff --git a/cwiki-common.el b/cwiki-common.el index 6569ac4..8ef14b7 100644 --- a/cwiki-common.el +++ b/cwiki-common.el @@ -141,7 +141,7 @@ (defun www-uri-decode-char (char-rep) (let (ccs cpos) (cond - ((string-match ":" char-rep) + ((string-match "%3A" char-rep) (setq ccs (substring char-rep 0 (match-beginning 0)) cpos (substring char-rep (match-end 0))) (setq ccs (www-uri-decode-feature-name ccs)) @@ -156,39 +156,47 @@ (if (numberp cpos) (decode-char ccs cpos)) ) - ((= (length char-rep) 1) - (aref char-rep 0) + (t + (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er)) + (when (= (length char-rep) 1) + (aref char-rep 0)) )))) (defun www-uri-encode-char (char) - (let ((ccs-list '(=ucs - =cns11643-1 =cns11643-2 =cns11643-3 - =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7 - =gb2312 =gb12345 - =jis-x0208 =jis-x0208@1990 - =jis-x0212 - =cbeta =jef-china3 - =jis-x0213-1@2000 =jis-x0213-1@2004 - =jis-x0208@1983 =jis-x0208@1978 - =zinbun-oracle - =daikanwa - =gt =gt-k - =big5 - =big5-cdp - =>>jis-x0208 =>>jis-x0213-1 - =>jis-x0208 =>jis-x0213-1)) - ccs ret) - (while (and ccs-list - (setq ccs (pop ccs-list)) - (not (setq ret (encode-char char ccs 'defined-only))))) - (cond (ret - (format "%s:0x%X" - (www-uri-encode-feature-name ccs) - ret)) - ((setq ccs (car (split-char char))) - (format "%s:0x%X" - (www-uri-encode-feature-name ccs) - (encode-char char ccs)))))) + (if (encode-char char '=ucs) + (mapconcat + (lambda (byte) + (format "%%%02X" byte)) + (encode-coding-string (char-to-string char) 'utf-8-mcs-er) + "") + (let ((ccs-list '(; =ucs + =cns11643-1 =cns11643-2 =cns11643-3 + =cns11643-4 =cns11643-5 =cns11643-6 =cns11643-7 + =gb2312 =gb12345 + =jis-x0208 =jis-x0208@1990 + =jis-x0212 + =cbeta =jef-china3 + =jis-x0213-1@2000 =jis-x0213-1@2004 + =jis-x0208@1983 =jis-x0208@1978 + =zinbun-oracle + =daikanwa + =gt =gt-k + =big5 + =big5-cdp + =>>jis-x0208 =>>jis-x0213-1 + =>jis-x0208 =>jis-x0213-1)) + ccs ret) + (while (and ccs-list + (setq ccs (pop ccs-list)) + (not (setq ret (encode-char char ccs 'defined-only))))) + (cond (ret + (format "%s:0x%X" + (www-uri-encode-feature-name ccs) + ret)) + ((setq ccs (car (split-char char))) + (format "%s:0x%X" + (www-uri-encode-feature-name ccs) + (encode-char char ccs))))))) ;;; @ Feature name presentation @@ -214,6 +222,10 @@ (symbol-name feature-name) "-")) (dest (upcase (pop rest)))) + (when (string-match "^=+>*" dest) + (setq dest (concat (substring dest 0 (match-end 0)) + " " + (substring dest (match-end 0))))) (cond (rest (while (cdr rest) @@ -581,8 +593,8 @@ nil t)) (encode-coding-region (point-min)(point-max) 'utf-8-mcs-er) (goto-char (point-min)) - (while (search-forward "&" nil t) - (replace-match "&" nil t)) + (while (search-forward ">-" nil t) + (replace-match "&GT-" nil t)) (buffer-string)))) (defun www-html-display-paragraph (text)