Log stripper/HTML balancer in Developer Help
|
|
Hey there guys, I've been trying to create a little script in DM that lets me run HTML logs created by BYOND through a filter and fix any missing closing tags so that I don't end up with...
<b>hi there</b><br> <i>sup bro<br> <b><u>dude bro what is up<br> <s>uh oh these tags are bleeding downwards<br> <tt>oh lord <i>this isn't good</tt><br>
|
Unfortunately it isn't going so well at all. It was suggested to me by a friend to split each line up by using the br tags as a reference point, which... well, I got that much down but I don't really know what I'm supposed to do next.
mob verb Strip() var log = file2text('thelog.htm')
src << browse(log, "window=log_raw")
var list/L = tokenize(log, "<br>")
for(var/line in L) src << html_encode(line)
proc tokenize(string, delimiter) . = list()
var len = length(delimiter)
lastpos = 1
pos = findtext(string, delimiter)
while(pos != 0) . += copytext(string, lastpos, pos)
lastpos = pos + len
pos = findtext(string, delimiter, lastpos)
. += copytext(string, lastpos)
|
I'm honestly not too worried about the tags being balanced (*b* *i* */b* */i*) though that would be a plus. I just want to be able to close any open tags so the logs are readable as you progress through them.
|