Putting "[/text]" inside [text]...[/text] pair

Q&A's, tips, howto's
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Putting "[/text]" inside [text]...[/text] pair

Post by cormullion »

I'm confused yet again! I want to describe the [text] and [/text] tags in some HTML text but I then have to enclose the entire HTML source in [text] ...[/text] tags so that newLISP can process the entire HTML. Obviously it doesn't work unless I do something to the non-active [text][/text] occurrences but I don't know what. Suggestions welcome...

Fanda
Posts: 253
Joined: Tue Aug 02, 2005 6:40 am
Contact:

Post by Fanda »

If you don't use '{' or '}' inside the text, use them instead:

Code: Select all

(define (test str)
  (println str))

(test {
  [text] Just testing... [/text]
})

Code: Select all

=>  [text] Just testing... [/text]
Fanda

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Thanks - I'll have another look at the problem...

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

... but {,} will not work for more than 2048 characters. What you can do is use the HTML code options: & # 9 1 ; and & # 9 3 ; for [ and ] respectively:

Code: Select all

(set 'str
[text]
this is about the & # 9 2 ; text & # 9 3 ;  tag
[/text])

; will display as
; this is about the [text] tag
; in a browser
Lutz

ps: I had to put spaces in between so it would not translate in this post

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Yes, that's the solution! Thanks - as usual, Lutz, you save the day!

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

And how to do this when reading large code of text that includes [text] and [/text] ? [text][text][/text][/text]

Im unable to get this working.. There seems to be no quoting for for this in normal text files...

Lutz, perhpas the parser function should always seek for the "last" occeurance of '[/text]' when reading/writing large newlisp code as text...??

Or do you have another hint?
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

'base64-enc'-ode bigger text portions of unknown content first, then bracket them with [text],[/text] tags, e.g:

Code: Select all

[text]dGhpcyBoYXMgW3RleHRdZW1iZWRkZWRbL3RleHRdIHRhZ3M=[/text]
Any other solution can lead to ambiguities.

Locked