livecode - Replacement only between begin{document} and \end{document} -
i have got of code stack-overflow , it's working, while changing code requirement(replacement between begin{document} , \end{document}) it's not working
this code got
put wordoffset("begin{document}",fld "mytextfield") tbegin put wordoffset("end{document}",fld "mytextfield") tend put replacetext(word tbegin tend of fld "mytextfield","bad","good") word tbegin tend of fld "mytextfield"
i using following code. how convert above code requirement.
on mouseup put htmltext of field "mytextfield" myhtml set casesensitive true put field srtext myarraytobe split myarraytobe cr put number of lines of (the keys of myarraytobe) myarraylength repeat = 1 myarraylength put myarraytobe[i] y split y colon put y[1] searchstr put y[2] replacestr if searchstr empty put 0 m else replace searchstr "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & searchstr & "</font></strike><font bgcolor=" & quote & "green" & quote & ">" & replacestr & "</font>" in myhtml end if end repeat set htmltext of fld "mytextfield" myhtml end mouseup
now think understand problem, try this...
on mouseup put htmltext of field "mytextfield" myhtml ## first need break myhtml 3 parts can edit "document" part... -- find document "begin" marker , put it's position tbegin variable put wordoffset("begin{document}",myhtml) tbegin -- find document "end" marker , put it's position tend variable put wordoffset("end{document}",myhtml) tend put word 1 tbegin of myhtml theader -- part 1 put word (tbegin +1) (tend -1) of myhtml tdocument -- part 2 = document change put word tend -1 of myhtml tfooter -- part 3 set casesensitive true put field "srtext" myarraytobe split myarraytobe cr put number of lines of (the keys of myarraytobe) myarraylength repeat = 1 myarraylength put myarraytobe[i] y split y colon put y[1] searchstr put y[2] replacestr if searchstr empty put 0 m else replace searchstr "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & searchstr & "</font></strike><font bgcolor=" & quote & "green" & quote & ">" & replacestr & "</font>" in tdocument end if end repeat ## can rebuild htmltext 3 parts , put in field... set htmltext of fld "mytextfield" theader && tdocument && tfooter end mouseup