WordPress.org

Support

Support » Requests and Feedback » needed: Word Wrap for Comments

needed: Word Wrap for Comments

  • i have built my site, using wordpress, and have been able to figure out every little problem that my friend and i could think of. you know, in the process of trying to build a flawless site that can’t be corrupted by jerks 🙂
    well, my friend corrupted it. he left a comment to one of the stories, and it was just “11111” times about 50. basically a total of 100+ “1”s in one line. well, instead of wrapping, or breaking the word, it just stretches my page:
    http://www.en4mation.com/wordpress/index.php?p=3
    now, i’ve tried to use some basic HTML to do it, then i tried using CSS. neither worked. this is very frustrating and i can’t figure it out. has there been a hack to fix this, or does anyone know how exactly to fix this problem so we don’t run into it once the page goes live?

Viewing 11 replies - 1 through 11 (of 11 total)
  • With the following, if there’s a long single word, it” be cut off (not wrapped)
    ol#commentlist {
    overflow: hidden;
    width: 400px;
    }

    well, i don’t think i want the post to just disapear, per ce. i’d like it to wrap, just because if someone wants to provide a URL, i’d like that URL to show in its entirety, just not to stretch the page. this seems like it would cut the comment, and that word, so that it wouldn’t be the link in its entirety.

    As long as the url is still clickable, you don’t need to see the whole thing to go to the site

    “There’s no way to wrap it other than to run a php function to split long words/strings of characters within a comment.” This is what I am looking for Kafkaesqui. I haven’t been able to find this hack in WordPress yet. Would anyone be interested in helping me impliment such a code on my site? The scrolling bar idea just doesn’t seem…attractive right now.

    I asked the same thing of the author of the recent_comment plugin I use – Krischen – the same day he provided a revised version with code added to split long text strings. Find the plugin here: http://blog.jodies.de/archiv/2004/11/13/recent-comments/

    oops! posted too soon – I meant to add – is this a way to solve the problem – the code adds a break in a long text string to enable the text to wrap correctly – proble with this solution is that long URL’s will be broken.

    OK I suck at this 🙁 … here’s Krischans explanation [I sure he wouldn’t mind me sharing :)] :
    $comment_short = preg_replace(“/([^\s]{30})/”,”$1 “,$comment_short);
    “Replace every bunch of 30 or more characters that are not equal whitespace with itself and add blank after it”. The 30 should be configurable, but php seems to not evualute a variable at that place.

    hah.. that plugin was released on my b-day ^_^.

    works like a charm for me – set at 90 chars with a space as my break character.

    ‘Flagged for Codex’

    Works like a champ…

    I had the same problem and cobbled together this hack from two or three other similar functions I saw on the net:

    function word_wrap($texte,$lng_max) {
    // Script
    $esp=explode(" ",$texte);
    $i=0;
    $carac_dep=0;
    $tmp_txt="";
    // sur tout la longeur du texte
    while ($i<=count($esp)) {
    $lng_mot=strlen($esp[$i]);
    // si le mot est trop gd
    if ($lng_mot>$lng_max) {
    // on decoupe
    $nb_f=($lng_mot/$lng_max)+1;
    $mot="";
    for ($j=0;$j<=$nb_f;$j++) {
    $mot.=substr($esp[$i],($j*$lng_max),$lng_max)."<br />";
    }
    $esp[$i]=$mot;
    }
    $tmp_txt.=$esp[$i]." ";
    $i++;
    }
    return $tmp_txt;
    }

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘needed: Word Wrap for Comments’ is closed to new replies.