forcing paragraphs with one line of text

Last post 07-13-2004, 2:51 PM by Aluminum. 8 replies.
Sort Posts: Previous Next
  •  06-17-2004, 12:09 PM 1047

    forcing paragraphs with one line of text

    Is there a way to force a one-line of text entry to be wrapped in P tags?

     
    We're finding that a lot of people are entering one line/paragraph of text and it's not getting wrapped in a paragraph.
     
    Hitting return at the end WILL wrap it in a paragraph, but will also add a second set of blank paragraph tags. It's be nice to have the editor default to a set of blank P tags for initial text entry.
     
     
  •  06-17-2004, 1:05 PM 1048 in reply to 1047

    Re: forcing paragraphs with one line of text

  •  06-21-2004, 3:21 PM 1062 in reply to 1048

    Re: forcing paragraphs with one line of text

    Adam:

     
    That thread has something to do with text wrapping. That's not my issue. I'm looking for a way to guarantee that ANY text entered in the editor is wrapped with a set of paragraph tags. Right now, a person can enter/modify a line of text, but if they never hit return at the end of it, P tags are never added.
     
    This is making it rather difficult to consistently apply CSS to the site.
     
     
  •  06-21-2004, 5:45 PM 1065 in reply to 1062

    Re: forcing paragraphs with one line of text

    You can defines what happens when the "enter" key is pressed in the editor in the BreakMode enumeration.This enumeration has three values.

    Member Name Description
    UseDivOnCarriageReturn use <div > tags on enter keypress instead of <p></p>tags
    UseBROnCarriageReturn use <br> tags on enter keypress instead of <p></p>tags
    UseParagrapOnCarriage Enter key inserts new paragraph

     


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-22-2004, 10:45 AM 1072 in reply to 1065

    Re: forcing paragraphs with one line of text

    Adam:

     
    Maybe I'm not explaining this clearly.

    The problem is that if the person *DOES NOT* press the enter key, the text is *NOT* wrapped in P tags.
     
    So, someone entering two paragraphs, will have two blocks of text wrapped in P tags.
     
    Someone entering one paragraph, and not hitting RETURN at the end has *NO* P tags.
     
    As such, the content is being entered inconsistently.
     
    Additionaly, if a person does enter one block of text and hits return, the first block is wrapped in P tags, but a second set of empty P tags are also included.
     
    These are both issues with the quality/consistency of the HTML being entered into our system.
  •  06-22-2004, 2:21 PM 1074 in reply to 1072

    Re: forcing paragraphs with one line of text

    Aluminum,

     
    You can use

    Editor.XHTML Property

    to retrieves the CuteEditor HTML content in well-formed XHTML format.
     
    I think that will resolve your problems.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-23-2004, 3:37 PM 1083 in reply to 1074

    Re: forcing paragraphs with one line of text

    I'll give that a shot...thanks!
  •  07-07-2004, 5:37 PM 1191 in reply to 1083

    Re: forcing paragraphs with one line of text

    Adam:

     
    Nope. That didn't fix things either.
     
    Can you log this as a bug? It's a fairly important issue for us.
     
    -Darrel
     
  •  07-13-2004, 2:51 PM 1243 in reply to 1191

    Re: forcing paragraphs with one line of text

    If anyone is interested, here's the fix I've built. It's not the prettiest thing, but works. We're calling this function on the SUBMIT button before the text is stored in the database. I hope it is of some use to someone...
     

    function checkForBlockTagWrappers (ByVal textToParse as String) as String
        ' set s as string that we'll return
        dim s as String
       
        ' check to confirm that there is actual text to parse
        ' (as opposed to a blank field)
        if textToParse <> "" then

        ' create a Regex to check for leading spaces and lines:   
        dim regexLeadingSpace as New Regex( _
            "(?<leadingSpace>(^(\s|\n)+))" & _
            "(?<EverythingElse>((.|\n)*))", RegexOptions.IgnoreCase)
        ' set each matched group to a string
        dim matchLeadingSpace as Match = regexLeadingSpace.Match(textToParse)
        dim strLeadingSpace as String = matchLeadingSpace.Groups("leadingSpace").Value.toString
        dim strEverythingElse as String = matchLeadingSpace.Groups("EverythingElse").Value.toString
        ' if there is a match for the leading space, then just use the second match (the text)
        if (strLeadingSpace > "") then
            ' check to make sure there is text after the leading spaces. If so, then
            ' use that text as the string to parse
            if strEverythingElse > ""
                textToParse = strEverythingElse
            ' otherwise, return nothing
            else
                s = ""
                return s
            end if
        else
        ' there are no leading spaces, so continue on
        end if

        ' create a Regex to check for the first word/tag. If a tag, it will return
        ' the opening bracket and the tag name. Ex: <table
        dim regexFirstWord as new regex( _
            "(?<firstWord>(\S[^\s/>]*))", RegexOptions.IgnoreCase)
        ' set the match as a string
        dim m1 as Match = regexFirstWord.Match(textToParse)
        dim firstWord as String = m1.Groups("firstWord").Value.toString
        ' set the first word to all lowercase (for comparing to tags)
        firstWord = microsoft.VisualBasic.LCase(firstWord)
        ' see if the first word is a block-level tag
        if  firstWord = "<address" or _
            firstWord = "<blockquote" or _
              firstWord = "<center" or _
            firstWord = "<dir" or _
            firstWord = "<div" or _
            firstWord = "<dl" or _
            firstWord = "<fieldset" or _
            firstWord = "<form" or _
            firstWord = "<h1" or _
            firstWord = "<h2" or _
            firstWord = "<h3" or _
            firstWord = "<h4" or _
            firstWord = "<h5" or _
            firstWord = "<h6" or _
            firstWord = "<hr" or _
            firstWord = "<isindex" or _
            firstWord = "<menu" or _
            firstWord = "<noframes" or _
            firstWord = "<noscript" or _
            firstWord = "<ol" or _
            firstWord = "<p" or _
            firstWord = "<pre" or _
            firstWord = "<table" or _
            firstWord = "<ul" or _
            firstWord = "<dd" or _
            firstWord = "<dt" or _
            firstWord = "<frameset" or _
            firstWord = "<li" or _
            firstWord = "<tbody" or _
            firstWord = "<td" or _
            firstWord = "<tfoot" or _
            firstWord = "<th" or _
            firstWord = "<thead" or _
            firstWord = "<tr" then
                ' if so, do nothing as it *appears* to be wrapped in a proper block-level tag
                s = textToParse
            else
                ' add default P tag wrappers
                s = "<p>" & textToParse & "</p>"
                ' if field contained spaces, then just delete it all
        end if
        return s

        ' else, if the field is empty, don't do anything
        else
        end if

    end function

View as RSS news feed in XML