[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
display html patch
- From: hsh@xxxxxxxxxxx (Henrik S. Hansen)
- Date: Sat, 16 Oct 2004 17:04:37 +0200
- X-ml-name: emacs-w3m
- X-mail-count: 07132
This is a patch to properly display some otherwise non-displayable HTML
character entities on the console (and in X with no matching fonts) --
by default they are displayed as ~ (tilde).
There are still definitions of w3m-ucs-to-char in some other files
(w3m-e21.el, etc.) -- I'm not sure what to replace those with.
Comments on the patch are very welcome.
Also, please enlighten me by answering these questions:
* Why is w3m-ucs-to-char defined both in w3m.el and other files (like
w3m-e21.el)?
* Why are non-displayable characters displayed as ~ (tilde) on an emacs
with mule-ucs, and ? (question mark) on an emacs without mule-ucs?
(I suspect this has something to do with decode-char in
w3m-ucs-to-char in w3m-e21.el, which seems to return nil with any
character argument with mule-ucs, but return integers without).
Author: Henrik S. Hansen <hsh@freecode.dk>
License: GNU General Public License, ver. 2 or newer
Date: 2004-10-16
For emacs-w3m-version: CVS 1.1070
diff -Naur emacs-w3m.orig/w3m.el emacs-w3m/w3m.el
--- emacs-w3m.orig/w3m.el 2004-10-16 14:59:07.000000000 +0200
+++ emacs-w3m/w3m.el 2004-10-16 16:33:31.000000000 +0200
@@ -2745,14 +2745,43 @@
(cdr elem))))
(eval-and-compile
- (unless (fboundp 'w3m-ucs-to-char)
- (defun w3m-ucs-to-char (codepoint)
- "A dummy function defined since nothing provided the regular function.
-This function simply returns the arg if it is between 0x20 and 0x7e,
-otherwise returns the tilde character."
+ (unless (fboundp 'w3m-ucs-to-string)
+ (defun w3m-ucs-to-string (codepoint)
+ "A dummy function defined since nothing provided the regular
+function. This function returns the string representation of
+CODEPOINT, if it is between 0x20 and 0x7e. Otherwise, we try to map
+CODEPOINT to a string resembling the HTML character entity, and return
+this. If this is not possible, a string with only the tilde character
+is returned."
(if (or (< codepoint 32) (< 127 codepoint))
- ?~ ;; unsupported character
- codepoint))))
+ (cond
+ ((= codepoint 8211) "-") ;; en dash
+ ((= codepoint 8212) "--") ;; em dash
+ ((= codepoint 8216) "`") ;; left single quote
+ ((= codepoint 8217) "'") ;; right single quote
+ ((= codepoint 8218) "'") ;; single low quote
+ ((= codepoint 8220) "\"") ;; left double quote
+ ((= codepoint 8221) "\"") ;; right double quote
+ ((= codepoint 8222) "\"") ;; double low quote
+ ((= codepoint 8224) "^") ;; dagger
+ ((= codepoint 8225) "^") ;; double dagger
+ ((= codepoint 8226) "*") ;; bullet
+ ((= codepoint 8230) "...") ;; ellipses
+ ((= codepoint 8240) "%.") ;; per mille (thousand)
+ ((= codepoint 8242) "'") ;; prime, minutes, feet
+ ((= codepoint 8243) "\"") ;; double prime, seconds, inches
+ ((= codepoint 8260) "/") ;; fraction slash
+ ((= codepoint 8482) "(tm)") ;; trademark
+ ((= codepoint 8592) "<-") ;; left arrow
+ ((= codepoint 8593) "^") ;; up arrow
+ ((= codepoint 8594) "->") ;; right arrow
+ ((= codepoint 8595) "v") ;; down arrow
+ ((= codepoint 8596) "<->") ;; left-right arrow
+ ((= codepoint 8656) "<=") ;; left double arrow
+ ((= codepoint 8658) "=>") ;; right double arrow
+ ((= codepoint 8660) "<=>") ;; left-right double arrow
+ (t (char-to-string ?~)))
+ (char-to-string codepoint)))))
(defun w3m-entity-value (name strict)
"Get a char corresponding to NAME from the html char entities database.
@@ -2773,7 +2802,7 @@
(let ((codepoint (if (char-equal (string-to-char name) ?x)
(string-to-number (substring name 1) 16)
(string-to-number name))))
- (char-to-string (w3m-ucs-to-char codepoint))))
+ (w3m-ucs-to-string codepoint)))
(let ((val (intern-soft name w3m-entity-db))
(pre name)
(post ""))
--
Henrik S. Hansen