Word Wrap in <PRE> ?

Discussion in 'HTML' started by Jimbo, Apr 15, 2005.

  1. Jimbo

    Jimbo Guest

    Hello,

    Is there a trick that allows lines to wrap under <PRE> instead of having
    them extend off the screen.

    I've looked around, but can't seem to find anything.

    TIA
    Jimbo, Apr 15, 2005
    #1
    1. Advertising

  2. Jimbo

    Steve Pugh Guest

    Jimbo <> wrote:

    >Is there a trick that allows lines to wrap under <PRE> instead of having
    >them extend off the screen.


    1. Put line breaks in your source code.
    2. Don't use <pre>
    3. Use CSS to set white-space: normal

    >I've looked around, but can't seem to find anything.


    Why are you using <pre> if you don't want the line breaks to be
    preformatted?

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Apr 15, 2005
    #2
    1. Advertising

  3. Jimbo

    Jimbo Guest

    In article <>,
    Steve Pugh <> wrote:

    > Jimbo <> wrote:
    >
    > >Is there a trick that allows lines to wrap under <PRE> instead of having
    > >them extend off the screen.

    >
    > 1. Put line breaks in your source code.
    > 2. Don't use <pre>
    > 3. Use CSS to set white-space: normal
    >
    > >I've looked around, but can't seem to find anything.

    >
    > Why are you using <pre> if you don't want the line breaks to be
    > preformatted?
    >
    > Steve


    Well, I'm setting up a site that allows the owners to use a cgi script
    to update the text on the site through their browser. It's very simple
    and it works great, but, right now, in order for them to separate
    paragraphs, they have to manually type in <br><br> in the textarea.

    I'm trying to eliminate that with a simple hit (or two) of the 'return'
    key.

    <pre> does that, but it also will not wrap the text -- so it's one
    looooong line off the right side of the screen.

    Thanks
    Jimbo, Apr 15, 2005
    #3
  4. Jimbo

    Steve Pugh Guest

    Jimbo <> wrote:
    > Steve Pugh <> wrote:
    >>
    >> Why are you using <pre> if you don't want the line breaks to be
    >> preformatted?

    >
    >Well, I'm setting up a site that allows the owners to use a cgi script
    >to update the text on the site through their browser. It's very simple
    >and it works great, but, right now, in order for them to separate
    >paragraphs, they have to manually type in <br><br> in the textarea.
    >
    >I'm trying to eliminate that with a simple hit (or two) of the 'return'
    >key.


    So change the CGI script to convert double returns into appropriate
    markup.

    ><pre> does that, but it also will not wrap the text -- so it's one
    >looooong line off the right side of the screen.


    Yes, that's what <pre> is supposed to do. You'll users will need to
    enter a return at the end of every line. More work for them, not less.
    Not a good idea.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Apr 15, 2005
    #4
  5. Jimbo

    Toby Inkster Guest

    Jimbo wrote:

    > Is there a trick that allows lines to wrap under <PRE> instead of having
    > them extend off the screen.


    In CSS 2.1 there is:

    <pre style="white-space:pre-wrap">
    ....
    </pre>

    It's even *supported* in one or two browsers!

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Apr 15, 2005
    #5
  6. Jimbo

    Toby Inkster Guest

    Jimbo wrote:

    > Well, I'm setting up a site that allows the owners to use a cgi script
    > to update the text on the site through their browser. It's very simple
    > and it works great, but, right now, in order for them to separate
    > paragraphs, they have to manually type in <br><br> in the textarea.


    $text = &get_data_from_database;
    $text =~ s/\n\n/<br><br>/g;
    print $text;

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Apr 15, 2005
    #6
  7. Toby Inkster wrote:
    > $text = &get_data_from_database;
    > $text =~ s/\n\n/<br><br>/g;
    > print $text;


    Or better:

    $text = &get_data_from_database;
    $text =~ s/\r|\n|\r\n/<br>/g;
    print $text;
    Leif K-Brooks, Apr 16, 2005
    #7
  8. Jimbo

    Dan Guest

    Toby Inkster wrote:
    > Jimbo wrote:
    >
    > > Well, I'm setting up a site that allows the owners to use a cgi

    script
    > > to update the text on the site through their browser. It's very

    simple
    > > and it works great, but, right now, in order for them to separate
    > > paragraphs, they have to manually type in <br><br> in the textarea.

    >
    > $text = &get_data_from_database;
    > $text =~ s/\n\n/<br><br>/g;
    > print $text;


    Though, if the intent is to mark up paragraphs, proper use of
    <p>...</p> elements would be more logical than the presentationalist
    use of <br><br>.

    --
    Dan
    Dan, Apr 16, 2005
    #8
  9. Jimbo

    DU Guest

    Jimbo wrote:

    > Hello,
    >
    > Is there a trick that allows lines to wrap under <PRE> instead of having
    > them extend off the screen.
    >
    > I've looked around, but can't seem to find anything.
    >
    > TIA


    pre
    {
    white-space: pre-wrap; /* CSS2.1 compliant */
    white-space: -moz-pre-wrap; /* Mozilla-based browsers */
    white-space: o-pre-wrap; /* Opera 7+ */
    }

    white-space: pre-wrap;
    http://www.w3.org/TR/CSS21/text.html#propdef-white-space

    Mozilla:
    http://lxr.mozilla.org/seamonkey/source/content/base/src/nsPlainTextSerializer.cpp#655

    "Opera accepts a non-standard value for the CSS2 white-space property,
    namely white-space: -o-pre-wrap."
    http://www.opera.com/docs/specs/#css

    DU
    --
    The site said to use Internet Explorer 5 or better... so I switched to
    Mozilla 1.7.6 :)
    DU, Apr 17, 2005
    #9
  10. Jimbo

    Toby Inkster Guest

    DU wrote:

    > pre
    > {
    > white-space: pre-wrap; /* CSS2.1 compliant */
    > white-space: -moz-pre-wrap; /* Mozilla-based browsers */
    > white-space: o-pre-wrap; /* Opera 7+ */
    > }


    You missed the hyphen in "-o-pre-wrap", but recent Operas support the CSS
    2.1 "pre-wrap" anyway.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Apr 17, 2005
    #10
  11. Jimbo

    DU Guest

    Toby Inkster wrote:

    > You missed the hyphen in "-o-pre-wrap",


    Correct :)

    > but recent Operas support the CSS
    > 2.1 "pre-wrap" anyway.


    Opera dev. software claim to support entirely CSS 2.1
    (but we know Opera 8.x does not support at all visibility: collapse).
    Regarding pre-wrap, I'll verify this.

    DU
    --
    The site said to use Internet Explorer 5 or better... so I switched to
    Mozilla 1.7.7 :)
    DU, Apr 18, 2005
    #11
  12. Jimbo

    Toby Inkster Guest

    DU wrote:

    > Opera dev. software claim to support entirely CSS 2.1
    > (but we know Opera 8.x does not support at all visibility: collapse).


    It does support "visibility:collapse", but there are some bugs when
    "visibility:collapse" is applied to elements with "display:table-*".

    Besdies which, I still don't think Opera claim to support *all* of CSS 2.1
    -- IIRC there are still some numbering systems that Opera doesn't support
    for ordered lists.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Apr 18, 2005
    #12
  13. Jimbo

    Jimbo Guest

    In article <q7Y7e.1858$>,
    Leif K-Brooks <> wrote:

    > Toby Inkster wrote:
    > > $text = &get_data_from_database;
    > > $text =~ s/\n\n/<br><br>/g;
    > > print $text;

    >
    > Or better:
    >
    > $text = &get_data_from_database;
    > $text =~ s/\r|\n|\r\n/<br>/g;
    > print $text;



    O.K... here's the deal, please keep in mind that I'm not very good at
    this.

    The scipt is here:

    http://mosaikum.org/sonst/pws.html

    And, I believe, the following is the part where the line breaks for
    'return' key need to be placed. How do I do it?(TIA):


    sub Bearb {

    if (($filename =~ m/[^\w\.\-_]/i) or (not($filename =~ m/\.txt$/)) )
    {$filename=""; $showerror='Error in Filename! Use only numbers, letters,
    "_" and "-". <br> File MUST end with .txt'; &Auswahl; return;}

    $title="Edit $filename";
    open (WISHANDLE, "$filename");
    while ($wisline = <WISHANDLE>) {
    $wisvar .= $wisline;
    }

    close (WISHANDLE);


    print qq!
    Jimbo, Apr 18, 2005
    #13
  14. in alt.html, Toby Inkster wrote:
    > DU wrote:
    >
    > > Opera dev. software claim to support entirely CSS 2.1
    > > (but we know Opera 8.x does not support at all visibility: collapse).

    >
    > It does support "visibility:collapse", but there are some bugs when
    > "visibility:collapse" is applied to elements with "display:table-*".


    That is matter of definition of support...

    > Besdies which, I still don't think Opera claim to support *all* of CSS 2.1
    > -- IIRC there are still some numbering systems that Opera doesn't support
    > for ordered lists.


    Of course, there is lots of stuff in CSS21 that Opera 8 doesn't fully
    support: Display:inline-block, position:absolute and overflow, overflow
    and tablestuff, float, :hover, + ...

    (haven't tested with RC yet though...)

    For example, as visibility:collapse and overflow are most useful with
    tables, and not useful without tables (IMHO), I would say that support
    for overflow and visibility:collapse does not exist...

    (but of course, there is even more things not supported in other
    browsers...)

    --
    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
    Utrecht, NL.
    Support me, buy Opera:
    https://secure.bmtmicro.com/opera/buy-opera.html?AID=882173
    Lauri Raittila, Apr 18, 2005
    #14
  15. Jimbo

    DU Guest

    Toby Inkster wrote:
    > DU wrote:
    >
    >
    >>Opera dev. software claim to support entirely CSS 2.1
    >>(but we know Opera 8.x does not support at all visibility: collapse).

    >
    >
    > It does support "visibility:collapse",


    I disagree.
    http://www.meyerweb.com/eric/css/tests/css2/sec11-02.htm
    https://bugzilla.mozilla.org/attachment.cgi?id=147933&action=view

    but there are some bugs when
    > "visibility:collapse" is applied to elements with "display:table-*".
    >
    > Besdies which, I still don't think Opera claim to support *all* of CSS 2.1
    > -- IIRC there are still some numbering systems that Opera doesn't support
    > for ordered lists.
    >


    Opera's CSS support (and claims to support CSS) is overrated. I tested
    carefully Opera 8 build 7561 with over 80 webpages and I saw many
    regressions and also what appears to be new rendering bugs. Anyway,
    maybe we should start a thread on that in c.i.w.a.stylesheets.

    Also, I am upset and disappointed by Opera's bug system report: they
    make you work absolutely for free for them (posting, filing, reporting,
    testcase, etc) while keeping you in the dark on everything on top of
    that. Sometimes the bug is resolved as WFM or wrongly and you never get
    a simple feedback. I stopped reporting bugs over there: it's an useless
    waste of time.

    DU
    DU, Apr 23, 2005
    #15
  16. Jimbo

    Csaba Gabor Guest

    DU wrote:
    > Also, I am upset and disappointed by Opera's bug system report: they
    > make you work absolutely for free for them (posting, filing, reporting,
    > testcase, etc) while keeping you in the dark on everything on top of
    > that. Sometimes the bug is resolved as WFM or wrongly and you never get
    > a simple feedback. I stopped reporting bugs over there: it's an useless
    > waste of time.


    Ditto that. I also stopped reporting bugs there for the same reason. It
    doesn't bother me so much whether they fix them or not, but I'd at least
    like to see when someone has made a decision about a bug report (and
    the reasoning). Basically, you want to know what you wrote was
    considered, even if disagreed with.

    That's why I'm happy to report issues to http://bugzilla.mozilla.org
    It might take a while, and I might be denied, but at least I see
    what's happening.

    Csaba Gabor from Vienna
    Csaba Gabor, Apr 24, 2005
    #16
  17. Jimbo

    DU Guest

    Csaba Gabor wrote:

    > DU wrote:
    >
    >> Also, I am upset and disappointed by Opera's bug system report: they
    >> make you work absolutely for free for them (posting, filing,
    >> reporting, testcase, etc) while keeping you in the dark on everything
    >> on top of that. Sometimes the bug is resolved as WFM or wrongly and
    >> you never get a simple feedback. I stopped reporting bugs over there:
    >> it's an useless waste of time.

    >
    >
    > Ditto that. I also stopped reporting bugs there for the same reason. It
    > doesn't bother me so much whether they fix them or not, but I'd at least
    > like to see when someone has made a decision about a bug report (and
    > the reasoning). Basically, you want to know what you wrote was
    > considered, even if disagreed with.
    >
    > That's why I'm happy to report issues to http://bugzilla.mozilla.org
    > It might take a while, and I might be denied, but at least I see
    > what's happening.
    >
    > Csaba Gabor from Vienna


    Thank you for reporting this. I was sure no one would or could defend
    such bug reporting system after an honest try. I ended up thinking that
    Opera's bug system is like a blind person communicating with a deaf and
    mute person and the blind person does not even know he's speaking to a
    deaf and mute person.

    Me in 2004: "The first time I filed bug reports at Opera was in January
    31st 2002. (...) making good testcase, filing bugs, pinpointing as best
    in what consist the bug often takes time."

    Sue Sims in 2004: "Indeed! You can't imagine how many test cases I've
    written, by de-composing the markup from a page, distilling it down to
    the bare essentials of what caused the problem."

    And there is no no compensation of any kind, form, shape for
    examining/investigating, filing, reporting, making testcase, etc.. doing
    all that for Opera.

    I have personally filed bugs publicly at MSIE 7 website on its standards
    support and everyone can see, read the bugs I've filed. I can not even
    do that with Opera!

    DU
    DU, Apr 24, 2005
    #17
  18. Jimbo

    tm Guest

    DU wrote:
    > Csaba Gabor wrote:
    > > DU wrote:


    > >> Also, I am upset and disappointed by Opera's bug system report: they
    > >> make you work absolutely for free for them (posting, filing,
    > >> reporting, testcase, etc) while keeping you in the dark on everything
    > >> on top of that. Sometimes the bug is resolved as WFM or wrongly and
    > >> you never get a simple feedback. I stopped reporting bugs over there:
    > >> it's an useless waste of time.

    > >
    > > Ditto that. I also stopped reporting bugs there for the same reason. It
    > > doesn't bother me so much whether they fix them or not, but I'd at least
    > > like to see when someone has made a decision about a bug report (and
    > > the reasoning). Basically, you want to know what you wrote was
    > > considered, even if disagreed with.
    > >
    > > That's why I'm happy to report issues to http://bugzilla.mozilla.org
    > > It might take a while, and I might be denied, but at least I see
    > > what's happening.


    > Thank you for reporting this. I was sure no one would or could defend
    > such bug reporting system after an honest try. I ended up thinking that
    > Opera's bug system is like a blind person communicating with a deaf and
    > mute person and the blind person does not even know he's speaking to a
    > deaf and mute person.
    >
    > Me in 2004: "The first time I filed bug reports at Opera was in January
    > 31st 2002. (...) making good testcase, filing bugs, pinpointing as best
    > in what consist the bug often takes time."
    >
    > Sue Sims in 2004: "Indeed! You can't imagine how many test cases I've
    > written, by de-composing the markup from a page, distilling it down to
    > the bare essentials of what caused the problem."
    >
    > And there is no no compensation of any kind, form, shape for
    > examining/investigating, filing, reporting, making testcase, etc.. doing
    > all that for Opera.
    >
    > I have personally filed bugs publicly at MSIE 7 website on its standards
    > support and everyone can see, read the bugs I've filed. I can not even
    > do that with Opera!


    I am impressed with your diligence, I thank you and the internets
    community thanks you. I personally have been complained to Oprah about
    the ridiculous advertizing banner, to no avail. Why anyone would use
    such an obviously inferior browser is beyond me.
    tm, Apr 25, 2005
    #18
  19. Jimbo

    kchayka Guest

    tm wrote:
    >
    > I personally have been complained to Oprah


    I didn't realize that Ms Winfrey's sphere of influence was so large. ;)

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
    kchayka, Apr 25, 2005
    #19
  20. Jimbo

    Steve Pugh Guest

    kchayka wrote:
    > tm wrote:
    > >
    > > I personally have been complained to Oprah

    >
    > I didn't realize that Ms Winfrey's sphere of influence was so large.

    ;)

    Well, it's varied a bit over the years...
    Steve Pugh, Apr 25, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    680
    Chronic Philharmonic
    May 10, 2008
  2. gabriele renzi
    Replies:
    1
    Views:
    135
    Mauricio Fernández
    Jun 1, 2004
  3. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    214
    Art Werschulz
    Sep 22, 2003
  4. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    229
    Anno Siegel
    Sep 25, 2003
  5. Jan Burse

    InlineView with pre-wrap

    Jan Burse, Jun 14, 2013, in forum: Java
    Replies:
    0
    Views:
    186
    Jan Burse
    Jun 14, 2013
Loading...

Share This Page