From yazicivo at ttnet.net.tr Mon Jul 16 11:13:27 2007 From: yazicivo at ttnet.net.tr (Volkan YAZICI) Date: Mon, 16 Jul 2007 14:13:27 +0300 Subject: [cl-who-devel] Exposing String Escape Functions Message-ID: <87ejj838ko.fsf@ttnet.net.tr> Hi, In a parser I'm working on, trying to convert hand-written documents into XHTML form. And for this purpose using CL-WHO integrated within META-SEXP. Because of character-by-character parsing, I need to escape unrecognized atoms on-the-fly. At the moment, I'm using below method. (elt (cl-who:escape-string (make-string 1 :initial-element character-needs-escaping)) 0) Yep, quite nasty code piece to escape a single character. Therefore, I'd ask if it'd be possible to expose the character escaping routines. (If you approve the proposal, I'm volunteered to send a patch.) Regards. From edi at agharta.de Mon Jul 16 11:24:33 2007 From: edi at agharta.de (Edi Weitz) Date: Mon, 16 Jul 2007 13:24:33 +0200 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: <87ejj838ko.fsf@ttnet.net.tr> (Volkan YAZICI's message of "Mon, 16 Jul 2007 14:13:27 +0300") References: <87ejj838ko.fsf@ttnet.net.tr> Message-ID: On Mon, 16 Jul 2007 14:13:27 +0300, Volkan YAZICI wrote: > In a parser I'm working on, trying to convert hand-written documents > into XHTML form. And for this purpose using CL-WHO integrated within > META-SEXP. Because of character-by-character parsing, I need to > escape unrecognized atoms on-the-fly. At the moment, I'm using below > method. > > (elt > (cl-who:escape-string > (make-string 1 :initial-element character-needs-escaping)) > 0) Hmm, I don't think I undertstand that. Grabbing just the first character will usually just give you the ampersand: CL-USER 1 > (let ((character-needs-escaping #\>)) (elt (cl-who:escape-string (make-string 1 :initial-element character-needs-escaping)) 0)) #\& Is that really what you want? From yazicivo at ttnet.net.tr Mon Jul 16 11:29:26 2007 From: yazicivo at ttnet.net.tr (Volkan YAZICI) Date: Mon, 16 Jul 2007 14:29:26 +0300 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: (Edi Weitz's message of "Mon\, 16 Jul 2007 13\:24\:33 +0200") References: <87ejj838ko.fsf@ttnet.net.tr> Message-ID: <87abtw37u1.fsf@ttnet.net.tr> Edi Weitz writes: > On Mon, 16 Jul 2007 14:13:27 +0300, Volkan YAZICI wrote: > Hmm, I don't think I undertstand that. Grabbing just the first > character will usually just give you the ampersand: > > CL-USER 1 > (let ((character-needs-escaping #\>)) > (elt > (cl-who:escape-string > (make-string 1 :initial-element character-needs-escaping)) > 0)) > #\& > > Is that really what you want? Execuse, that's my fault. I realized the mistake after I pressed C-c C-c. Here's a small snippet from the real code: (write-string (cl-who:escape-string (make-string 1 :initial-element c)) some-output-stream) Regards. From edi at agharta.de Mon Jul 16 11:56:07 2007 From: edi at agharta.de (Edi Weitz) Date: Mon, 16 Jul 2007 13:56:07 +0200 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: <87abtw37u1.fsf@ttnet.net.tr> (Volkan YAZICI's message of "Mon, 16 Jul 2007 14:29:26 +0300") References: <87ejj838ko.fsf@ttnet.net.tr> <87abtw37u1.fsf@ttnet.net.tr> Message-ID: On Mon, 16 Jul 2007 14:29:26 +0300, Volkan YAZICI wrote: > Execuse, that's my fault. I realized the mistake after I pressed C-c > C-c. Here's a small snippet from the real code: > > (write-string > (cl-who:escape-string (make-string 1 :initial-element c)) > some-output-stream) OK, I see. It's fine with me if you want to isolate the corresponding code and export a function which works on characters as long as your patch adheres with these guidelines: http://weitz.de/patches.html Go wild, Edi. From yazicivo at ttnet.net.tr Mon Jul 16 13:35:40 2007 From: yazicivo at ttnet.net.tr (Volkan YAZICI) Date: Mon, 16 Jul 2007 16:35:40 +0300 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: (Edi Weitz's message of "Mon\, 16 Jul 2007 13\:56\:07 +0200") References: <87ejj838ko.fsf@ttnet.net.tr> <87abtw37u1.fsf@ttnet.net.tr> Message-ID: <87644k31zn.fsf@ttnet.net.tr> Edi Weitz writes: > On Mon, 16 Jul 2007 14:29:26 +0300, Volkan YAZICI wrote: >> (write-string >> (cl-who:escape-string (make-string 1 :initial-element c)) >> some-output-stream) > > OK, I see. > > It's fine with me if you want to isolate the corresponding code and > export a function which works on characters as long as your patch > adheres with these guidelines: > > http://weitz.de/patches.html -------------- next part -------------- A non-text attachment was scrubbed... Name: cl-who-escape-char.patch Type: text/x-diff Size: 4757 bytes Desc: CL-WHO ESCAPE-CHAR Patch URL: -------------- next part -------------- I attached the related patch with the post. But if you'd ask for my opinion, escaping functions are just polluting function namespace. IMHO, it would be better to collect them under a single generic function. (Also by preserving old ones for compatibility.) For instance: (defmethod escape ((input character) &optional test) ...) (defmethod escape ((input string) &optional text) ...) And then we just supply the related escape predicates as global variables. (This time we pollute variable namespace.) Another, suggestion: (defmethod escape ((type (eql :ascii)) (input character)) ...) (defmethod escape ((type (eql :ascii)) (input string)) ...) (defmethod escape ((type (eql :minimal)) ...) ...) ... By the way, (eq *html-node* :xml) checks in the code make FORMAT optimization impossible for character escaping routines. I didn't test the impact of this from the performance point of view, but how many clients there are that doesn't support hexadecimals in the escaped entities? (Maybe let that check as a compile time parameter?) Anyway, I'm just thinking loudly and sure you'll conclude to the best. Regards. From rnewman at twinql.com Tue Jul 17 04:42:53 2007 From: rnewman at twinql.com (Richard Newman) Date: Mon, 16 Jul 2007 21:42:53 -0700 Subject: [cl-who-devel] CL-WHO mlisp patch Message-ID: Edi, folks, Here's a one-line patch to make CL-WHO 0.9.1 compile cleanly on Allegro CL's modern mode. -R --- specials-old.lisp 2007-04-27 02:33:42.000000000 -0700 +++ specials.lisp 2007-07-16 21:32:02.000000000 -0700 @@ -96,7 +96,7 @@ "The list of HTML tags that should be output as empty tags. See *HTML-EMPTY-TAG-AWARE-P*.") -(defvar *html-empty-tag-aware-p* T +(defvar *html-empty-tag-aware-p* t "Set this to NIL to if you want to use CL-WHO as a strict XML generator. Otherwise, CL-WHO will only write empty tags listed in *HTML-EMPTY-TAGS* as \(XHTML mode) or \(SGML From edi at agharta.de Thu Jul 19 21:44:19 2007 From: edi at agharta.de (Edi Weitz) Date: Thu, 19 Jul 2007 23:44:19 +0200 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: <87644k31zn.fsf@ttnet.net.tr> (Volkan YAZICI's message of "Mon, 16 Jul 2007 16:35:40 +0300") References: <87ejj838ko.fsf@ttnet.net.tr> <87abtw37u1.fsf@ttnet.net.tr> <87644k31zn.fsf@ttnet.net.tr> Message-ID: Sorry for the delay. Busy... On Mon, 16 Jul 2007 16:35:40 +0300, Volkan YAZICI wrote: > I attached the related patch with the post. Thanks. That's OK with me except that I'd use FLET instead of LET for the test functions. But the patch for the HTML documentation is missing. > But if you'd ask for my opinion, escaping functions are just > polluting function namespace. I don't think that's a big issue because we have packages. CL-WHO only exports two dozens of symbols or so. > IMHO, it would be better to collect them under a single generic > function. Yeah, but it'd be "harder" to use. Again, I think this is not a big issue and mainly a matter of taste. > By the way, (eq *html-node* :xml) checks in the code make FORMAT > optimization impossible for character escaping routines. I didn't > test the impact of this from the performance point of view, but how > many clients there are that doesn't support hexadecimals in the > escaped entities? (Maybe let that check as a compile time > parameter?) I agree that it'd be nicer to make this a compile-time decision. I'm not so much concerned about performance, but it'd be good for consistency. Thanks, Edi. From yazicivo at ttnet.net.tr Thu Jul 19 21:54:37 2007 From: yazicivo at ttnet.net.tr (Volkan YAZICI) Date: Fri, 20 Jul 2007 00:54:37 +0300 Subject: [cl-who-devel] Exposing String Escape Functions In-Reply-To: (Edi Weitz's message of "Thu\, 19 Jul 2007 23\:44\:19 +0200") References: <87ejj838ko.fsf@ttnet.net.tr> <87abtw37u1.fsf@ttnet.net.tr> <87644k31zn.fsf@ttnet.net.tr> Message-ID: <87y7hcgiua.fsf@ttnet.net.tr> Edi Weitz writes: > But the patch for the HTML documentation is missing. I totally missed to diff index.html. Here it is. Regards. -------------- next part -------------- A non-text attachment was scrubbed... Name: cl-who-escape-char-doc.patch Type: text/x-diff Size: 2444 bytes Desc: not available URL: From edi at agharta.de Tue Jul 24 21:57:44 2007 From: edi at agharta.de (Edi Weitz) Date: Tue, 24 Jul 2007 23:57:44 +0200 Subject: [cl-who-devel] New release 0.10.0 (Was: Exposing String Escape Functions) In-Reply-To: <87644k31zn.fsf@ttnet.net.tr> (Volkan YAZICI's message of "Mon, 16 Jul 2007 16:35:40 +0300") References: <87ejj838ko.fsf@ttnet.net.tr> <87abtw37u1.fsf@ttnet.net.tr> <87644k31zn.fsf@ttnet.net.tr> Message-ID: On Mon, 16 Jul 2007 16:35:40 +0300, Volkan YAZICI wrote: > I attached the related patch with the post. The patch contained TAB characters and wrong links amongst other things, so I had to go through it manually anyway. That's why it took me a while. Here's the new release. Thanks, Edi.