Print Page | Close Window

forcing a line break in editor

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5395
Printed Date: 03 April 2026 at 12:27am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: forcing a line break in editor
Posted By: beej
Subject: forcing a line break in editor
Date Posted: 31 August 2003 at 12:21pm
Hi, i did a quick search for line break probs etc..couldnt find anything, but im sure ive read it in here somewhere..

the prob is, im experimenting with a 779pixel wide format for my pages, and i noticed if a user types in a long string of txt in the editor, it forces the table apart, thus disjointing the whole page. Is there any way of forcing a line break automatically?



Replies:
Posted By: God_Struth
Date Posted: 31 August 2003 at 5:33pm
Something to do with word wrap, but I'll be shackled if I can remember what the whole answer was..


Posted By: beej
Date Posted: 31 August 2003 at 5:35pm
the editor word wraps fine, im talking about someone typing in something like thisssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.


Posted By: fernan82
Date Posted: 31 August 2003 at 9:25pm

The only way to prevent was from happening would be to first check what's the longest the string could be without stretching the tables and then on the function that formats the posts add some code to split the post in words and check the lenght of each word and if it's too long split them in two (or whatever it takes depending on the lenght) and add a dash so that a long string like the one you just posted would be converted to something like thisssssssssssssssssssssssssssssssssssssssssssssssssssssssssss- sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss ...

Another solution would be to rewrite the HTML of the forum_posts.asp so that each post uses a table of it's own, that way if somebody posts a long string it would only mess up the layout of that post and not the whole page..... that's what most forums do.

Either one of these solutions won't we too easy to implement and IMO is not worth all that hassle...  also the first one will probably affect performance since you'd have to split the post in words and check each word one by one...



Posted By: beej
Date Posted: 31 August 2003 at 9:30pm
thanks for the reply, is there a way of the editor only allowing, say, a maximum single word limit? like say 60 characters or something..


Posted By: fernan82
Date Posted: 31 August 2003 at 9:43pm

No, I don't think there's a way to do that.



Posted By: ljamal
Date Posted: 31 August 2003 at 9:55pm
The easiest solution would be to write a function that checks the number of characters between spaces. If that number is greater than a certain number then return an error and allow the user to edit their post.

Realistically, no one should post a string of characters longer than 25-30 characters. This check would only have to be performed on post and edits, so the additional overhead would be minimal.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: WebWiz-Bruce
Date Posted: 01 September 2003 at 3:08am
The biggest problem with checking the length of a word and forcing a line break if over a certain length is that it would also break links, images, etc., thus making the links, etc. not work.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: ljamal
Date Posted: 01 September 2003 at 7:15am
If all the URLs are prefaced with http:// then you can ignore those.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: WebWiz-Bruce
Date Posted: 01 September 2003 at 7:29am

But not all are also what about images etc. there are many HTML lines that would get lost breaking up long characters.

It can be dones using CSS but it seems that it is not yet implemeted correctly in IE and so doesn't always work within a table.



-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: ljamal
Date Posted: 01 September 2003 at 7:35am
Ignoring HTML is not a huge problem and neither is is ignoring the WWF tags. I worked on a function to do this at one time and it worked for plain text, but I never got around to expanding it for HTML, maybe I will pull it out at some point and adapt it for HTML.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: WebWiz-Bruce
Date Posted: 01 September 2003 at 7:55am

There are functions already in the forum that strip HTML and another that strips just the text. Maybe I could look at using these for spliting plain text within a post do the line breaking problem. Replacing with a space would probally be better then the line wrap would deal with the line break on it's own.

I shall look into it.



-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Bunce
Date Posted: 01 September 2003 at 4:50pm

FYI.  This forum concatenates any URL links posted so that they don't cause this wrapping issue. Not sure if its worth the trouble to do but thought I'd mention it anyway:

http://forums.whirlpool.net.au/ - http://forums.whirlpool.net.au/

So http://www.SomeReallyLongURLLinkGoesHere.com - www.SomeReallyLongURLLinkGoesHere.com becomes something like:
http://www.SomeReal.....com - www.SomeReal.....com

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: WebWiz-Bruce
Date Posted: 04 September 2003 at 7:23am

After 3 days about 10 hours I have written a function for the forum that will split long strings by placing line breaks into them.

The difficult part wasn't stripping the HTML the problem was splitting long strings at every xx length.

The there was the problem of links if they contained the same text in the href link part as the displayed text both would be changed using the replace fuction. So I have to replace all href HTML tags with a code palcing both original HTML link and code into a two dimesional array to place back into the message at the end so that the HTML tag part of the link was not effected.

Anyway heres the function that needs to be placed in the functions_filter.asp file and called to from the post_message.asp file.

[code]'******************************************
'***     Split long text strings ***
'******************************************

'Function to strip out long words, long rows of chars, and long text lines from text
Private Function removeLongText(ByVal strMessageInput)

 Dim lngMessagePosition  'Holds the message position
 Dim intHTMLTagLength  'Holds the length of the HTML tags
 Dim strHTMLMessage  'Holds the HTML message
 Dim strTempMessageText  'Temp store for the message input
 Dim strTempPlainTextWord 'Holds the plain text word
 Dim saryPlainTextWord  'Array holding the plain text words
 Dim sarySplitTextWord()  'Array holding the plain text word that has been split
 Dim lngSplitPlainTextWordLoop 'Loop counter for looping through the pain text split word
 Dim strTempOutputMessage 'Outputted string
 Dim intWordSartPos  'Holds the location in the word to start the split
 Dim saryHTMLlinks()  'Holds links from the message and thier corrisponding code
 Dim strHTMLlinksCode  'Holds the code that is replaced the links with
 Dim lngLoopCounter  'loop counter to count the number of HTML links in meesage
 Dim blnHTMLlink   'Set to true if there is a link in the message body
 Const intMaxWordLength = 60 'Holds the max word lentgh (can't be below 22 or will mess up the link code placed into messages)
 
 
 'Initliase variables
 lngLoopCounter = 0
 blnHTMLlink = False
 
 'Place the message input into a temp store
 strTempMessageText = strMessageInput
 strTempOutputMessage = strMessageInput
 

 '**********************************
 '**** Strip HTML from message *****
 '**********************************
 
 'Loop through each character in the post message
 For lngMessagePosition = 1 to CLng(Len(strMessageInput))

  'If this is the end of the message then save some process time and jump out the loop
  If Mid(strMessageInput, lngMessagePosition, 1) = "" Then Exit For
  
  'If an HTML tag is found then jump to the end so we can strip it
  If Mid(strMessageInput, lngMessagePosition, 1) = "<" Then

   'Get the length of the HTML tag
   intHTMLTagLength = (InStr(lngMessagePosition, strMessageInput, ">", 1) - lngMessagePosition)
   
   'If the end of the HTML string is in error then set it to the number of characters being passed
   If intHTMLTagLength < 0 Then intHTMLTagLength = CLng(Len(strTempMessageText))

   'Place the HTML tag back into the temporary message store
   strHTMLMessage = Mid(strMessageInput, lngMessagePosition, intHTMLTagLength + 1)
   
   
   '***************************************** *****
   '**** Remove links so they aren't changed *****
   '***************************************** *****
   
   'See if the HTML tag is a link, if so replace with a code so it is not changed when spliting long chars
   If InStr(1, strHTMLMessage, "href", 1) Then
    
    'Add 1 to the loop counter
    lngLoopCounter = lngLoopCounter + 1
    
    'Redim the array, use preserve to keep the old array parts
    ReDim Preserve saryHTMLlinks(2,lngLoopCounter)
    
    'Create a code to replace the link with in original string
    strHTMLlinksCode = " **/**WWFlink00" & lngLoopCounter & "**\** "
    
    'Place the code and the original link into the array
    saryHTMLlinks(1,lngLoopCounter) = strHTMLlinksCode
    saryHTMLlinks(2,lngLoopCounter) = strHTMLMessage
    
    'Rpleace the HTML tag with the new code that is saved in array
    strTempOutputMessage = Replace(strTempOutputMessage, strHTMLMessage, strHTMLlinksCode, 1, -1, 0)
   
    'A link is found so set the link found variable to true
    blnHTMLlink = True
   End If
   '***************************************** **********
 
   'Strip the HTML
   strTempMessageText = Replace(strTempMessageText, strHTMLMessage, " ", 1, -1, 0)
  End If
 Next
 

 '********************************************
 '**** Check for and remove long strings *****
 '********************************************
 
 'Now we have just the text (no HTML) in plain text variable see if any of the text strings in it are over 30 chars in length
 saryPlainTextWord = Split(Trim(strTempMessageText), " ")
 
 'Loop through all the words till they are shortened
 For lngLoopCounter = 0 To UBound(saryPlainTextWord)
  
  'If the text string length is more than the max word length then place spaces in the text string
  If Len(saryPlainTextWord(lngLoopCounter)) > intMaxWordLength Then
   
   'Redim the array (don't use preserve as we want to loose the last data in the array)
   Redim sarySplitTextWord(CInt(Len(saryPlainTextWord(lngLoopCounter) )/intMaxWordLength+1))
   
   'Initiliase variable
   intWordSartPos = 1
   
   'Loop through all the splits in the word
   For lngSplitPlainTextWordLoop = 1 To UBound(sarySplitTextWord)
   
    'Place the split word into the array
    sarySplitTextWord(lngSplitPlainTextW ordLoop) = Mid(saryPlainTextWord(lngLoopCounter), intWordSartPos, intMaxWordLength)

    'Add max word length to the start position
    intWordSartPos = intWordSartPos + intMaxWordLength
   Next
   
   'Place the split up long text string back together in one variable with spaces at the max word length
   strTempPlainTextWord = Join(sarySplitTextWord, " ")
   
   'Place the split up word back into the orginal message
   strTempOutputMessage = Replace(strTempOutputMessage, saryPlainTextWord(lngLoopCounter), strTempPlainTextWord, 1, -1, 0)
  End If

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Posted By: wistex
Date Posted: 06 September 2003 at 7:49pm

Wow!  Nice bit of work!

I'm glad someone finally solved that problem!!!



-------------
http://www.wistex.com" rel="nofollow - WisTex Solutions
http://www.caribbeanchoice.com/forums" rel="nofollow - CaribbeanChoice Forums


Posted By: beej
Date Posted: 06 September 2003 at 10:47pm
awesome work!, sorry to be a pain, but how do i call the function in the post_message.asp. file?. I tried this:

'removelong strings function
removeLongText = strMessageInput

but wsnt sure where it went in the file...



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net