Page 1 of 1

LC insists on interpreting HTML code

Posted: Sun Dec 23, 2018 10:46 pm
by kaveh1000
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?

Re: LC insists on interpreting HTML code

Posted: Mon Dec 24, 2018 4:49 am
by FourthWorld
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.

Re: LC insists on interpreting HTML code

Posted: Mon Dec 24, 2018 1:59 pm
by kaveh1000
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.

Re: LC insists on interpreting HTML code

Posted: Mon Dec 24, 2018 6:28 pm
by FourthWorld
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.

Re: LC insists on interpreting HTML code

Posted: Tue Dec 25, 2018 1:33 am
by kaveh1000
"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...

Re: LC insists on interpreting HTML code

Posted: Thu Dec 27, 2018 2:56 am
by FourthWorld
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. ;)

Re: LC insists on interpreting HTML code

Posted: Thu Dec 27, 2018 11:30 am
by kaveh1000
I would not normally be forgiving, but I will make an exception as it is the festive period. ;-) Happy holidays and New Year. :-)

Re: LC insists on interpreting HTML code

Posted: Thu Dec 27, 2018 2:06 pm
by [-hh]
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.

Re: LC insists on interpreting HTML code

Posted: Thu Dec 27, 2018 2:58 pm
by kaveh1000
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.