Showing posts with label htmltext. Show all posts
Showing posts with label htmltext. Show all posts

Thursday, July 23, 2009

Text index to Html Index conversion

This week I was working on an enhancement to add highlighting, patterned underline, and strikethrough functionality to the textArea control of flex. I ran into a problem keeping track of the position of the text highlighted when the user edits the content. So I decided to wrap the highlighted text in html tags such as . My problem was that I needed an algorithm to conver text to html index.

After rigourous searching I found Andrei Ionescu post on this. I liked his method but reading through the comments I saw someone saying something about regular expressions and I thought to myself why not use regular expressions to help preprocess the html instead of character parsing.

Eventually I came up with this method and here I post it for anyone interested, feel free to use it.