Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - forcing a line break in editor
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

forcing a line break in editor

 Post Reply Post Reply Page  <12
Author
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 01 September 2003 at 7:15am
If all the URLs are prefaced with http:// then you can ignore those.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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/

So www.SomeReallyLongURLLinkGoesHere.com becomes something like:
www.SomeReal.....com

Cheers,
Andrew



Edited by Bunce
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
wistex View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 30 August 2003
Location: United States
Status: Offline
Points: 877
Post Options Post Options   Thanks (0) Thanks(0)   Quote wistex Quote  Post ReplyReply Direct Link To This Post Posted: 06 September 2003 at 7:49pm

Wow!  Nice bit of work!

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

Back to Top
beej View Drop Down
Newbie
Newbie


Joined: 31 August 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote beej Quote  Post ReplyReply Direct Link To This Post 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...
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.