[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Converting a string to valid XHTML id?
From: |
Davis Herring |
Subject: |
Re: Converting a string to valid XHTML id? |
Date: |
Wed, 1 Dec 2010 07:34:00 -0800 (PST) |
User-agent: |
SquirrelMail/1.4.8-5.el5_4.10.lanl3 |
> (let ((old (assoc id org-newhtml-escaped-ids))
Wouldn't it be easier to do something like percent encoding? Map
everything that isn't [-.a-zA-Z0-9] onto _HH. Multibyte characters could
be handled by writing their UTF-8 encoding, or else by escaping as _nHH...
where n is the number of hex digits needed (itself always a single digit):
;; Uses Emacs' internal encoding instead of UTF-8 proper.
(defun org-newhtml-escape-id (str)
"Return a valid xhtml id attribute string.
See URL `http://xhtml.com/en/xhtml/reference/attribute-data-types/#id'."
(replace-regexp-in-string
"[^-.a-zA-Z0-9]" (lambda (c)
(mapconcat (lambda (d) (format "_%02x" d))
(string-as-unibyte c) "")) str))
Certainly someone could already have an id "foo_5fbar", but the
table-based implementation already makes the assumption that all IDs will
be generated by it.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
- Re: Converting a string to valid XHTML id?, Lennart Borgman, 2010/12/01
- Re: Converting a string to valid XHTML id?,
Davis Herring <=
- Re: Converting a string to valid XHTML id?, rm, 2010/12/01
- Re: Converting a string to valid XHTML id?, Davis Herring, 2010/12/01
- Re: Converting a string to valid XHTML id?, Lennart Borgman, 2010/12/01
- Re: Converting a string to valid XHTML id?, Davis Herring, 2010/12/01
- Re: Converting a string to valid XHTML id?, Lennart Borgman, 2010/12/01
- Re: Converting a string to valid XHTML id?, Davis Herring, 2010/12/01
- Re: Converting a string to valid XHTML id?, Lennart Borgman, 2010/12/01
- Re: Converting a string to valid XHTML id?, Davis Herring, 2010/12/01
- Re: Converting a string to valid XHTML id?, Lennart Borgman, 2010/12/01
Re: Converting a string to valid XHTML id?, Stefan Monnier, 2010/12/01