Page 1 of 1

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

Posted: Fri Jan 27, 2006 9:11 pm
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...

Posted: Sat Jan 28, 2006 2:05 am
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

Posted: Sat Jan 28, 2006 10:06 pm
by cormullion
Thanks - I'll have another look at the problem...

Posted: Sun Jan 29, 2006 1:46 am
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

Posted: Sun Jan 29, 2006 8:11 am
by cormullion
Yes, that's the solution! Thanks - as usual, Lutz, you save the day!

Posted: Fri Nov 21, 2008 8:31 pm
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?

Posted: Sat Nov 22, 2008 3:17 am
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.