ID:944853
 
(See the best response by Albro1.)
Code:
proc/FormatHTML(var/F)
var/TEXT=""
var/counter=1
while(findtext(F,"\n",counter,0))
var/SubLine="[copytext(F,counter,findtext(F,"\n",counter,0))]<br>"
counter=findtext(F,"\n",counter,0)+1
TEXT+=SubLine
return TEXT


Problem description:i wrote up this proc so everyline which has \n instead of
the proc will just remove it but now the problem is this proc is adding 2 line break instead of 1 making alot more space.

Best response
Why not just grab the text before the \n and the text after it, effectively cutting out the \n?

var
part_one
part_two
while(findtext(F, "\n"))
part_one = copytext(F, 1, findtext(F, "\n"))
part_two = copytext(F, findtext(F, "\n")+2)
F = part_one + part_two
Or, use a text handling library like, Keeth's.
and use the replace text function to filter out all the \n?
The problem is that you're not removing the \n. You're actually just adding a <br> after each.
and, essentially <br> is the same as \n when it comes to formatting in the output.
sorry if the code is too much
mob/verb
ViewUpdates()
set hidden=1
winset(src,"UpdatesWindow","is-visible=true;pos=100,100")
winset(src,"UpdatesWindow.Current Version","text=\"Current Update Version: [GameVersion]\"")
src.ShowRecentChanges()

mob/proc/ShowRecentChanges()
var/Header={"<title>Dragon Ball Z Update Notes</title>
<body link=blue alink=blue vlink=blue>
<font face="Verdana" size=2 color=
[rgb(64,64,64)]>

Recent Updates - Most Recent at Top<br>
<b>Help Keep the Game Running Smoothly<br>
Post any Bugs you Find on the Forums</b><br>
<a href='http://uh2.darkerlegendsbyond.com'>Report A Bug</a><p>"}

var/datum/UpdateDatum/UD
var/HTML
for(var/datum/UpdateDatum/UDD in AllUpdates) if(UDD.Version==global.GameVersion) {UD=new UDD.type;break}
if(UD)
HTML={"
[UD.ReleaseDate]
Version
[UD.Version]
"}

if(UD.General||UD.Added||UD.Changed)
if(UD.General) HTML+="[UD.General]"
if(UD.Added) {HTML+="*Added:";HTML+="[UD.Added]"}
if(UD.Changed) {HTML+="*Changed:";HTML+="[UD.Changed]"}
else
HTML+="<B>Oops it appears Developers forgot to write update log"
HTML={"[Header][FormatHTML(HTML)]</font>"}

else
HTML={"
It Appears the Developers forgot to write up some update logs
"}

src<<output(HTML,"UpdatesWindow.Browser")
mob/verb/ViewFullUpdates()
set hidden=1
var/Header={"<title>Dragon Ball Z Update Notes</title>
<body link=blue alink=blue vlink=blue>
<font face="Segoe UI" size=2 color=
[rgb(96,96,96)]>

Recent Updates - Most Recent at Top<br>
<b>Help Keep the Game Running Smoothly<br>
Post any Bugs you Find on the Forums</b><br>
<a href='http://uh2.darkerlegendsbyond.com'>Report A Bug</a><p>"}

var/HTML={"[Header]"}
var/list/UpdateList=AllUpdates
for(var/datum/UpdateDatum/UD in UpdateList)
if(UD.General||UD.Added||UD.Changed)//This will only show to HTML if either of them have something to show.
HTML+={"[UD.ReleaseDate]<br>"}
HTML+="Version [UD.Version]<br>"
if(UD.General) HTML+="[FormatHTML(UD.General)]<br>"
if(UD.Added) {HTML+="*Added:<br>";HTML+="[FormatHTML(UD.Added)]"}
if(UD.Changed) {HTML+="*Changed:<br>";HTML+="[FormatHTML(UD.Changed)]"}
HTML+="</p>"
UpdateList-=UD
src<<browse(HTML,"window=News;size=600x600")
proc/FormatHTML(var/F)
var/TEXT=""
var/counter=1
while(findtext(F,"\n",counter,0))
var/SubLine="[copytext(F,counter,findtext(F,"\n",counter,0))]<br>"
counter=findtext(F,"\n",counter,0)+1
TEXT+=SubLine
return TEXT
proc/FindAndReplace(var/fullText,var/text2Find,var/replacementText)
var/replacedText=fullText
if(findtext(fullText,text2Find))
var/foundText=findtext(fullText,text2Find)
replacedText=copytext(replacedText,1,foundText)+replacementText+copytext(replacedText,foundText+length(text2Find))
return replacedText
var/list/AllUpdates=typesof(/datum/UpdateDatum/)
proc/PopulateUpdates()
for(var/V in AllUpdates)
AllUpdates+=new V
AllUpdates-=V
AllUpdates=SortDatumList(AllUpdates,"Version")
datum/UpdateDatum
var/Version=1//require Update version otherwise it will cause runtime error
var/ReleaseDate="??-??-????"
var/Added={""}
var/Changed={""}
var/General={""}
V0_1
Version=1
ReleaseDate="10-07-2012"
General={"
Begaining of the Game
"}

Added={"
-Some Character (Dont remember which ones)
-NPC Ai Guarding Dragon Balls
"}

Changed={"
Removed Guard Bar
"}

the problem is when i use the FindAndReplace() proc it doesnt split the text but with the code above it makes space for extra line.