emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] Entity markup


From: J. Bromley
Subject: [emacs-wiki-discuss] Entity markup
Date: Tue, 8 Feb 2005 01:04:59 +0000 (UTC)
User-agent: slrn/0.9.8.1 (Linux)

Hello all,

I was looking through some of the sources emacs-wiki generated and I noted
that ampersands, greater than and less than signs were not being properly
converted to entities. Is this a known problem?

I looked at the code and there's the function emacs-wiki-escape-html-specials
that does the proper substitution. However, I noticed it is only called in
some of the emacs-wiki-*-tag functions, but not anywhere is it applied to
normal text. It seems that it should be a simple matter to insert the call,
and after a bit of examination, I created a new markup rule in
emacs-wiki-publishing-markup and modified emacs-wiki-escape-html-specials to
handle the apostrophe.

I am submitting a patch, but to me it just feels really kludgey. My one
concern is if it plays nice with emacs-wiki-markup-entity. I believe it does,
and have done some tests that seem to indicate that it does, but as I don't
use many entities I'm not sure. If nothing else, the patch can serve and an
indication of what is wrong and perhaps some of those more skilled with the
emacs-wiki code can make use of it.

Cheers, patch follows.


--- emacs-wiki-publish.el.stable        2005-02-07 16:43:48.651930088 -0800
+++ emacs-wiki-publish.el       2005-02-07 16:42:54.983088992 -0800
@@ -1,4 +1,4 @@
-;;; emacs-wiki-publish.el --- Routines that publish an emacs-wiki project.
+
 
 ;; Copyright (C) 2001, 2002, 2003, 2004 John Wiegley
 ;; Copyright (C) 2004 Sacha Chua
@@ -471,6 +471,9 @@
 
    ["&\\([-A-Za-z_#0-9]+\\);" 0 emacs-wiki-markup-entity]
 
+   ;; Handle normal HTML specials &<>"'
+   ["[&()\"\']" 0 emacs-wiki-escape-html-specials]
+
    ;; change the displayed title or the stylesheet for a given page
    ["^#\\(menu\\|title\\|date\\|style\\|related\\)\\s-+\\(.+\\)\n+" 0
     emacs-wiki-markup-initial-directives]
@@ -1215,7 +1218,7 @@
 
 (defun emacs-wiki-escape-html-specials (&optional end)
   (while (and (or (not end) (< (point) end))
-              (re-search-forward "[<>&\"]" end t))
+              (re-search-forward "[<>&\"\']" end t))
     (cond
      ((eq (char-before) ?\")
       (delete-char -1)
@@ -1228,7 +1231,10 @@
       (insert "&gt;"))
      ((eq (char-before) ?\&)
       (delete-char -1)
-      (insert "&amp;")))))
+      (insert "&amp;"))
+     ((eq (char-before) ?\')
+      (delete-char -1)
+      (insert "&apos;")))))
 
 ;; Copied from w3m-url-encode-string (w3m.el)
 (defun emacs-wiki-escape-url (str &optional coding)

-- 
--| Jay Bromley |--| jbromley at gmail dot com |-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]