PDA

View Full Version : ASP Source Viewer - ASP & HTML formatting views


ghell
05-02-2004, 01:45 PM
I am making an ASP Source Viewer which reads an ASP file with FSO and displays it in <pre> tags then adds teh easy to read asp formatting found in many viewers and IDEs such as vs.net ("<%" has yellow background etc).

the problem is that html has different colouring to asp and i need to somehow get the file to work out weather it is asp or html (like in asp "<" is black, in html its blue... also in asp "If" is blue but in html it is black)

i have tried several methods of trying to get the file to do conditional formatting different on html from asp but none seem to work, i have tried splitting "<%" and "%>" and using regular expressions but i couldnt get either to work properly (im not very good with regex but i dont think it would work anyway) and splitting removed "<%"s and "%>"s but when i try to put them back it puts it around the html too

has anyone got any other ideas or modifications of these ideas for the formatting?

M@rco
05-03-2004, 10:51 PM
I am making an ASP Source Viewer which reads an ASP file with FSO and displays it in <pre> tags then adds teh easy to read asp formatting found in many viewers and IDEs such as vs.net ("<%" has yellow background etc).

the problem is that html has different colouring to asp and i need to somehow get the file to work out weather it is asp or html (like in asp "<" is black, in html its blue... also in asp "If" is blue but in html it is black)

i have tried several methods of trying to get the file to do conditional formatting different on html from asp but none seem to work, i have tried splitting "<%" and "%>" and using regular expressions but i couldnt get either to work properly (im not very good with regex but i dont think it would work anyway) and splitting removed "<%"s and "%>"s but when i try to put them back it puts it around the html too

has anyone got any other ideas or modifications of these ideas for the formatting?I would approach conditional formatting by using two regular expressions to split the code into substrings which can then be processed for formatting.

The first would separate the code into blocks of ASP and XHTML/HTML code, and the second (consisting of whitespaces and line breaks) would break each block into matchable substrings.

I suggest that the formatting itself would be best approached by using an XML document to hold the formatting information, and then using a simple XPath query (with two variable parameters - whether to look up an ASP or X/HTML name) to retrieve the matching node, and allow you to apply the appropriate formatting.

This would be highly maintainable, and as a final touch the formatting document could be cached at application level as a Free-Threaded DOM, so that the document was only parsed once (for maximum performance).

Helpful enough for once?! :p :D

ghell
06-19-2004, 07:41 AM
the prob when i try this is that for some reason it always seems to put a <%%> on the first line (or something like that, long time since i looked at this script) and i cant find any examples anywhere of scripts that do this properly (although i have seen a few that do it, i cant get any source snippets or author help from these people)

do you have any examples of how to split it between asp and (x)html as this is the part i couldnt work out


it took so long to answer because the notification email never got to me btw :confused: