Re: HTML to text in field
Hmm . . . On 9/8/2018 4:21 pm, David V Glasgow via use-livecode wrote: Thanks Richmond, I will mess about with your suggestions. It's always much appreciated when someone takes the time to suggest a complete handler. But …. I want more! * **Just as long as I can call you Oliver Twist. :)* Can you see anything wrong with this? replaceText (ttemp, "<*>", "|") * **Dunno, I have NEVER used replaceText. One thing I do know is that the in-built Dictionary in LC 7.1.4 is much more Richmond-friendly than that in the 8 and 9 series. Might not be a bad idea to try double quotes round 'ttemp': yes, I know that sounds bonkers, but . . . Ah, wait a malformed moment . . . I think you have got 'that' all wrong insofar as I don't think you can use a string-variable as the first term inside the brackets of a replaceText thingy (I use the term 'thingy' advisably as I haven't a clue whether replaceText is a function or something else) . . . Have a go with this ever so-slightly retro, mechanical thing: put ttemp into fld "TTTEMP" replaceText (fld "TTTEMP", "<*>", "|" Well it is probably a better bet than a sharp stick in the eye! * or have a clue about the error message? “button "Import HTML": execution error at line 7 (Handler: can't find handler) near "replaceText", char 1” *Read "my crap" above. Gosh, this Belarussian Stout really makes me 'artistic'. Richmond. * Cheers, David G ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Possibly as it was lifted verbatim from "elsewhere'. :/ Although it works the way it is in LC 8.1.10. Richmond. On 9/8/2018 4:31 pm, Richard Gaskin via use-livecode wrote: Richmond Mathewson wrote: >put (URL ("file:" & it),"UTF8") into CHEESE Was uniDecode intended there? -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.com http://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Hi David, I’m working on something thing similar at the moment (although I’m stripping out almost everything except for basic HTML formatting). I too found that nugget by JLG and had the similar results. I’ve also looked at using XML and regex. The problem with HTML is that while it’s a standard, unless it’s strict xHtml, it’s not really and a lot of it ends up being malformed, etc. Todays browsers are very forgiving and figure most of it out, but if you open the dev tools in safari or firefox and look at most pages, you will see a LOT of errors. So I don’t think there is an “out of the box” answer. My solution is similar to what you are trying, stripping out tags and some other things and cleaning it up to give me what I want. If your solution (after fixing the function vs command syntax that Klaus pointed out) doesn’t work for you, I could put together an example stack using my “cleaner” to share. I don’t claim it’s the best, only or anything else way to do it, other than it works for me and am happy to share. Best, Steve MacLean > On Aug 9, 2018, at 8:00 AM, David V Glasgow via use-livecode > wrote: > > Hello folks, > > I am having an interesting time (MacOS 10.13.5 LC 8.1.9) trying to load some > HTML files (≤ 5 ish MB). Most of them will be lists or tables, generated by > various users on various systems. > > I don’t want to retain any of the formatting, except line endings, so I would > be happy for tables to appear as lists. I found a little 2013 nugget from > the estimable Jacqueline Landman Gay > > set the htmltext of the templatefield to htmlVar -- variable contains the > html string > put the text of the templatefield into tPlainText > > In some cases that works fine, but in others, it seems that HTML tables > consisting of maybe 20-30 thousand rows are rendered onto a single line of > the field. A sort of black-letters-overwritten splodge appears in the first > row and LC cranks up to 100% of the processor and BBoD ensues. > > Sometimes it never seems to recover, but other times it hands back control > after maybe 20 minutes or so, and in those cases I can see the text if I set > dontwrap to false. It contains no line endings from the original table, and > a shedload of tabs. > > I have tried to operate on the HTML string in a variable before putting it > into the field, but frankly don’t really know what property of some HTML > tables might mean that line endings are lost. I can only see when I > examine the files in an editor. > > I tried a different approach, replacing a row end with a cr, and then > stripping out tags: > > put URL ("file:" & theFilePath) into ttemp > > replace "" with cr in ttemp > > replaceText (ttemp, "<*>", "|") > > filter lines of ttemp without empty > > set the text of field "import" to ttemp > > > The replaceText line generates an error “button "Import HTML": execution > error at line 7 (Handler: can't find handler) near "replaceText", char 1” > > Firstly I don’t get the error, and secondly I am worried I may be over > complicating something which should be simple. > > Advice please! > > Best wishes, > > David Glasgow > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
D’OH! > On 9 Aug 2018, at 2:23 pm, Klaus major-k via use-livecode > wrote: > > > "replacetext ()" is a FUNCTION and not a handler! :-) ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Richmond Mathewson wrote: >put (URL ("file:" & it),"UTF8") into CHEESE Was uniDecode intended there? -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Hi David, > Am 09.08.2018 um 15:21 schrieb David V Glasgow via use-livecode > : > > Thanks Richmond, I will mess about with your suggestions. It's always much > appreciated when someone takes the time to suggest a complete handler. > But …. I want more! Can you see anything wrong with this? > > replaceText (ttemp, "<*>", "|") > or have a clue about the error message? > “button "Import HTML": execution error at line 7 (Handler: can't find > handler) near "replaceText", char 1” "replacetext ()" is a FUNCTION and not a handler! :-) > Cheers, > > David G Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Thanks Richmond, I will mess about with your suggestions. It's always much appreciated when someone takes the time to suggest a complete handler. But …. I want more! Can you see anything wrong with this? replaceText (ttemp, "<*>", "|") or have a clue about the error message? “button "Import HTML": execution error at line 7 (Handler: can't find handler) near "replaceText", char 1” Cheers, David G ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: HTML to text in field
Well, although this might sound a bit goofy, how about just bunging your html text into a scrolling list field and every time you came across a moving down to a new line? This works: on mouseUp set the text of fld "SLF1" to empty answer file "Choose an HTML file to import" if the result = "cancel" then exit mouseUp else put (URL ("file:" & it),"UTF8") into CHEESE end if put 1 into LYNE repeat until CHEESE is empty if word 1 of CHEESE is "" then add 1 to LYNE delete word 1 of CHEESE else put word 1 of CHEESE after line LYNE of fld "SLF1" delete word 1 of CHEESE end if end repeat end mouseUp where fld "SLF1" is a scrolling list field. Admittedly it makes a pig's breakfast out of everything else. Richmond. On 9/8/2018 3:00 pm, David V Glasgow via use-livecode wrote: Hello folks, I am having an interesting time (MacOS 10.13.5 LC 8.1.9) trying to load some HTML files (≤ 5 ish MB). Most of them will be lists or tables, generated by various users on various systems. I don’t want to retain any of the formatting, except line endings, so I would be happy for tables to appear as lists. I found a little 2013 nugget from the estimable Jacqueline Landman Gay set the htmltext of the templatefield to htmlVar -- variable contains the html string put the text of the templatefield into tPlainText In some cases that works fine, but in others, it seems that HTML tables consisting of maybe 20-30 thousand rows are rendered onto a single line of the field. A sort of black-letters-overwritten splodge appears in the first row and LC cranks up to 100% of the processor and BBoD ensues. Sometimes it never seems to recover, but other times it hands back control after maybe 20 minutes or so, and in those cases I can see the text if I set dontwrap to false. It contains no line endings from the original table, and a shedload of tabs. I have tried to operate on the HTML string in a variable before putting it into the field, but frankly don’t really know what property of some HTML tables might mean that line endings are lost. I can only see when I examine the files in an editor. I tried a different approach, replacing a row end with a cr, and then stripping out tags: put URL ("file:" & theFilePath) into ttemp replace "" with cr in ttemp replaceText (ttemp, "<*>", "|") filter lines of ttemp without empty set the text of field "import" to ttemp The replaceText line generates an error “button "Import HTML": execution error at line 7 (Handler: can't find handler) near "replaceText", char 1” Firstly I don’t get the error, and secondly I am worried I may be over complicating something which should be simple. Advice please! Best wishes, David Glasgow ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
HTML to text in field
Hello folks, I am having an interesting time (MacOS 10.13.5 LC 8.1.9) trying to load some HTML files (≤ 5 ish MB). Most of them will be lists or tables, generated by various users on various systems. I don’t want to retain any of the formatting, except line endings, so I would be happy for tables to appear as lists. I found a little 2013 nugget from the estimable Jacqueline Landman Gay set the htmltext of the templatefield to htmlVar -- variable contains the html string put the text of the templatefield into tPlainText In some cases that works fine, but in others, it seems that HTML tables consisting of maybe 20-30 thousand rows are rendered onto a single line of the field. A sort of black-letters-overwritten splodge appears in the first row and LC cranks up to 100% of the processor and BBoD ensues. Sometimes it never seems to recover, but other times it hands back control after maybe 20 minutes or so, and in those cases I can see the text if I set dontwrap to false. It contains no line endings from the original table, and a shedload of tabs. I have tried to operate on the HTML string in a variable before putting it into the field, but frankly don’t really know what property of some HTML tables might mean that line endings are lost. I can only see when I examine the files in an editor. I tried a different approach, replacing a row end with a cr, and then stripping out tags: put URL ("file:" & theFilePath) into ttemp replace "" with cr in ttemp replaceText (ttemp, "<*>", "|") filter lines of ttemp without empty set the text of field "import" to ttemp The replaceText line generates an error “button "Import HTML": execution error at line 7 (Handler: can't find handler) near "replaceText", char 1” Firstly I don’t get the error, and secondly I am worried I may be over complicating something which should be simple. Advice please! Best wishes, David Glasgow ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode