Author |
Topic  |
|
daviswj
Starting Member
USA
8 Posts |
Posted - 27 November 2005 : 14:36:18
|
Incorporated the Tables Mod some time ago into a Snitz 3.4.04 install and think it's a great mod, however it has never successfully removed for me line breaks which are placed within the table definition.
With a table defined as: [table table] [tr table] [td table] cell one [/td] [/tr] [/table] each of these line breaks shows up as white space above the table on the rendered page. Defining the same table on a single line "[table table][tr table][td table]cell one[/td][/tr][/table]" works fine but can make editing the post more complex/confusing, causing members to make errors in their table definitions.
I'm not skilled in asp, however looking at the code shown in the mod:
dim tblCode, ftrLoc, ftdLoc, ftrClo, ftdClo, ftblEn, JoinBack
dim ftblBr, clearBreaksS1, clearBreaksS2
tblCode = Split(fString, "[table")
For i=0 to Ubound(tblCode)
ftblBr = InStr(tblCode(i), " table]")
ftrLoc = InStr(tblCode(i), "[tr")
ftdLoc = InStr(tblCode(i), "[td")
ftrClo = InStr(tblCode(i), "[/tr]")
ftdClo = InStr(tblCode(i), "[/td]")
ftblEn = InStr(tblCode(i), "[/table]")
ClearBreaksS1 = Left(tblCode(i), ftblEn)
ClearBreaksS2 = Replace(ClearBreaksS1, "<br>", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, "<br />", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, Chr(10), " ")
tblCode(i) = replace(tblCode(i), ClearBreaks1, ClearBreaks2)
if ftdLoc > ftrLoc and _
(ftdClo > ftdLoc and ftdClo < ftrClo) and _
(ftrClo < ftblEn and ftrClo > ftdClo) and _
ftblEn > ftrClo and _
CountSubs(tblCode(i), "[tr")=CountSubs(tblCode(i), "[/tr]") and _
CountSubs(tblCode(i), "[td")=CountSubs(tblCode(i), "[/td]") and _
CountSubs(fString, "[/table]")=Ubound(tblCode) then
tblCode(i) = replace(tblCode(i), " align=center", " align=""center""")
tblCode(i) = replace(tblCode(i), " align=left", " align=""left""")
tblCode(i) = replace(tblCode(i), " align=right", " align=""right""")
tblCode(i) = replace(tblCode(i), " valign=top", " valign=""top""")
tblCode(i) = replace(tblCode(i), " valign=bottom", " valign=""bottom""")
tblCode(i) = replace(tblCode(i), "[tr", "<tr")
tblCode(i) = replace(tblCode(i), "[td", "<td")
tblCode(i) = replace(tblCode(i), "[/td]", "</td>")
tblCode(i) = replace(tblCode(i), "[/tr]", "</tr>")
tblCode(i) = replace(tblCode(i), "[/table]", "</table>")
tblCode(i) = replace(tblCode(i), " table]", ">")
JoinBack = "<table"
else
JoinBack = "[table"
end if
Next
fString = Join(tblCode, JoinBack)
... it appears to my uneducated eye that the variables in the line
tblCode(i) = replace(tblCode(i), ClearBreaks1, ClearBreaks2) may be "typo'd" and perhaps should be "ClearBreaksS1" & "ClearBreaksS2". Making that change on my Forum eliminated the excess line breaks placed between forum table tags, however it also removed any line breaks legitimately found within each table cell's content. A Bad Thing .
I'm thinking I need to mod the mod so that cell content doesn't have line breaks replaced. Comments or suggestions appreciated ...
Bill Davis
|
|
daviswj
Starting Member
USA
8 Posts |
Posted - 28 November 2005 : 12:38:11
|
Tinkered with the code and so far this appears to work: dim tblCode, ftrLoc, ftdLoc, ftrClo, ftdClo, ftblEn, JoinBack
dim ftblBr, clearBreaksS1, clearBreaksS2, tblCode2, tdEnd
tblCode = Split(fString, "[table")
For i=0 to Ubound(tblCode)
ftblBr = InStr(tblCode(i), " table]")
ftrLoc = InStr(tblCode(i), "[tr")
ftdLoc = InStr(tblCode(i), "[td")
ftrClo = InStr(tblCode(i), "[/tr]")
ftdClo = InStr(tblCode(i), "[/td]")
ftblEn = InStr(tblCode(i), "[/table]")
' ######## modified code section to remove line breaks from within table definitions (WJD) #########
' while leaving line breaks within table cells or outside the table definition intact.
if Ubound(tblCode) >= 1 and i <> 0 then
tblCode2 = Split(tblCode(i), "[td ")
For i2=0 to Ubound(tblCode2)
tdEnd = InStr(tblCode2(i2), "[/td]")
if i2 = 0 then
ClearBreaksS1 = Right(tblCode2(i2), Len(tblCode2(i2)) - (tdEnd))
else
ClearBreaksS1 = Right(tblCode2(i2), Len(tblCode2(i2)) - (tdEnd + 3))
end if
If InStr(ClearBreaksS1, "[/table]") <> 0 Then ClearBreaksS1 = Left(ClearBreaksS1, InStr(ClearBreaksS1, "[/table]"))
ClearBreaksS2 = Replace(ClearBreaksS1, "<br>", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, "<br />", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, Chr(10), " ")
tblCode2(i2) = replace(tblCode2(i2), ClearBreaksS1, ClearBreaksS2)
Next
tblCode(i) = Join(tblCode2, "[td ")
end if
' ####### deleted section of original mod ########
' ClearBreaksS1 = Left(tblCode(i), ftblEn)
' ClearBreaksS2 = Replace(ClearBreaksS1, "<br>", " ")
' ClearBreaksS2 = Replace(ClearBreaksS2, "<br />", " ")
' ClearBreaksS2 = Replace(ClearBreaksS2, Chr(10), " ")
' tblCode(i) = replace(tblCode(i), ClearBreaks1, ClearBreaks2)
' ####### end deleted section #######
' ####### end modifed code section (WJD) #######
if ftdLoc > ftrLoc and _
(ftdClo > ftdLoc and ftdClo < ftrClo) and _
(ftrClo < ftblEn and ftrClo > ftdClo) and _
ftblEn > ftrClo and _
CountSubs(tblCode(i), "[tr")=CountSubs(tblCode(i), "[/tr]") and _
CountSubs(tblCode(i), "[td")=CountSubs(tblCode(i), "[/td]") and _
CountSubs(fString, "[/table]")=Ubound(tblCode) then
tblCode(i) = replace(tblCode(i), " align=center", " align=""center""")
tblCode(i) = replace(tblCode(i), " align=left", " align=""left""")
tblCode(i) = replace(tblCode(i), " align=right", " align=""right""")
tblCode(i) = replace(tblCode(i), " valign=top", " valign=""top""")
tblCode(i) = replace(tblCode(i), " valign=bottom", " valign=""bottom""")
tblCode(i) = replace(tblCode(i), "[tr", "<tr")
tblCode(i) = replace(tblCode(i), "[td", "<td")
tblCode(i) = replace(tblCode(i), "[/td]", "</td>")
tblCode(i) = replace(tblCode(i), "[/tr]", "</tr>")
tblCode(i) = replace(tblCode(i), "[/table]", "</table>")
tblCode(i) = replace(tblCode(i), " table]", ">")
JoinBack = "<table"
else
JoinBack = "[table"
end if
Next
fString = Join(tblCode, JoinBack)
... removing line breaks within table definitions, while leaving cell contents, line breaks between table definitions, and posts without any tables alone.
For what it's worth ..., Bill Davis |
Edited by - daviswj on 02 January 2006 06:42:25 |
 |
|
|
Topic  |
|
|
|