0

I am currently trying to write an application which invloves syntax highlighting codes. (HTML, XML, PHP, JavaScript, CSS and preferably more).

It has been going very well but I have come across a probelm: syntax highlighting. I have written a class for syntax highlighting XML myself, but it is incredibly slow, inefficient and takes so long. I loaded, as a test, a 600 line XML document, and it took two whole minutes to syntax highlight. What do people recommend for Syntax Highlighting on Android? Are there any good libraries? Are there any good algorithms I can use (I don't mind rewriting it from another language), or any standard techniques? What about Regex?

I also have the problem that when I did the 600-line XML test yesterday the EditText widget I was using could not cope with the coloured text and eventually I recieved a ANR error, but that is a different question I will post elsewhere, though if anyone does incidentally have a solution that would be great.

Thanks so much!

Henry Thompson
  • 2,441
  • 3
  • 23
  • 31

1 Answers1

0

You already have a lots of syntax highlighting tools available in Javascript. You may need to do slight modifications. Take a look at this. I use it in my blog everyday.

bragboy
  • 34,892
  • 30
  • 114
  • 171
  • Thanks very much! It doesn't seem a perfect solution but I'm sure it will work. It's really just a question of is it fast enough. I'll try it though. Thanks! – Henry Thompson Sep 07 '11 at 18:55
  • @RandomGuy: It IS fast enough! I have done the syntax highlighting for lots of lines.. Take a look at this link http://www.technicalypto.com/search/label/TRIE to see how fast it does. Plus it supports all known language formats like Java, c, C++, ruby, html, xml what not – bragboy Sep 07 '11 at 18:57
  • Oh sorry I didn't realise that it was actually highlighting it as the page loaded- I thought it had syntax highlighted it beforehand! Ok, then that is great. I will see how it works. Thanks again! – Henry Thompson Sep 07 '11 at 19:00