LC insists on interpreting HTML code

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

LC insists on interpreting HTML code

Post by kaveh1000 » Sun Dec 23, 2018 10:46 pm

I have some text with HTML code on some lines. It is not complete HTML code. e.g. no <p> tags.

When I put the text in a field I see it with the HTML tags, as expected. But when I try to search for the tags using say matchChunk, it does not find them as it seems to automatically have interpreted them.

I have not set the HTMLtext, just using it as pure text in a variable.

When I use "answer" to see the code, again I see the partial HTML code interpreted. Please see attached shot of a field with the tags showing correctly, but the tags interpreted in an answer dialog. Any ideas how I can force LC to read text and not to interpret?
Attachments
Screenshot 2018-12-23 at 21.40.21.png
Kaveh

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC insists on interpreting HTML code

Post by FourthWorld » Mon Dec 24, 2018 4:49 am

The answer command will do that (see its Dictionary entry).

To spot check while you're working consider either the Variable Watcher or the Message Box.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: LC insists on interpreting HTML code

Post by kaveh1000 » Mon Dec 24, 2018 1:59 pm

Thank you Richard. I have now looked at the documentation for "Answer" and can see it looks for html code and interprets it when it can.

In my case I found a solution. I still can't understand why but if I have a some text in myVar that contains "</font>" and if I say:

Code: Select all

if "</font>" is in line 5 of myVar then answer "yes"
it does not work but if I say:

Code: Select all

get line 5 of myVar
if "</font>" is in it then answer "yes"
I get a hit. The problem is solved, but it would be good to understand the reason for this.
Kaveh

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC insists on interpreting HTML code

Post by FourthWorld » Mon Dec 24, 2018 6:28 pm

In the second example "it" is referring to something other than myVar.

If you post an example stack or the complete code I'm sure we can fix this for you quickly.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: LC insists on interpreting HTML code

Post by kaveh1000 » Tue Dec 25, 2018 1:33 am

"it" is referring to "line 5 of myVar", no?

So when I extract line 5 and test that I can test for the HTML code, but when I refer directly to that line, LC interprets the HTML first.

Thank you very much for the offer Richard. I tried it in a minimal stack and the effect is not present and the stack I am working on has too many things going on.

It could be something to do with the stack. At least it is working nicely now...
Kaveh

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC insists on interpreting HTML code

Post by FourthWorld » Thu Dec 27, 2018 2:56 am

kaveh1000 wrote:
Tue Dec 25, 2018 1:33 am
"it" is referring to "line 5 of myVar", no?
You're absolutely right. I should know better than to try to answer forum posts in between rounds of eggnog. :)
So when I extract line 5 and test that I can test for the HTML code, but when I refer directly to that line, LC interprets the HTML first.

Thank you very much for the offer Richard. I tried it in a minimal stack and the effect is not present and the stack I am working on has too many things going on.

It could be something to do with the stack. At least it is working nicely now...
If you get stuck again please revisit this thread with a complete handler and we'll sort it out. Next time I promise to post without eggnog. ;)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: LC insists on interpreting HTML code

Post by kaveh1000 » Thu Dec 27, 2018 11:30 am

I would not normally be forgiving, but I will make an exception as it is the festive period. ;-) Happy holidays and New Year. :-)
Kaveh

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: LC insists on interpreting HTML code

Post by [-hh] » Thu Dec 27, 2018 2:06 pm

Kaveh,

just try the following. It works as it should.
So the problem may be that you have an unusual linedelimiter in your code? Or an otherwise different variable myVar?

Code: Select all

on mouseUp
  put "1"&cr&"2"&cr&"3"&cr&"4"&cr&"5<font></font>"&cr&"6" into myVar
  get line 5 of myVar
  if "</font>" is in it then answer "yes"
  if "</font>" is in line 5 of myVar then answer "yes"
end mouseUp
As to your original post (where, by the way, the colorizing should also include the opening backslash of the LaTeX command) you could simply replace "<font" with "<ffont" if you don't want the html interpretation.
shiftLock happens

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: LC insists on interpreting HTML code

Post by kaveh1000 » Thu Dec 27, 2018 2:58 pm

Thank you for your time on this...

I have not reset linedelimiter in the code...

Good hint to change the html code temporarily. I find that we have to be very careful whenever there is "<" in the source text. So to be safe, I am temporarily changing this to a unique string before saving the htmltext, then changing back in a field.
Kaveh

Post Reply

Return to “Talking LiveCode”