in reply to Re: Formatting CGI script error messages
in thread Formatting CGI script error messages

Just specifying a fixed-width font doesn't address the problem of wanting to preserve whitespace -- HTML collapses multiple consecutive spaces to single spaces, and also treats newlines as spaces.

Using <pre> tags after "hard-wrapping" the text to a reasonable width is certainly an option, but I thought it would be nicer if it wrapped to the browser's window size. A fixed paragraph width can't account for variations in the font size in each user's browser.

- Steve

  • Comment on Re^2: Formatting CGI script error messages

Replies are listed 'Best First'.
Re^3: do it dynamically
by ww (Archbishop) on Nov 17, 2004 at 14:00 UTC
    You don't have to use just one "fixed paragraph width."

    Set it, per user, dynamically. Browser detection provides you a basis to infer a maximum char_count that should be useable on the narrowest_likely screen. And in some cases, ENV detection can give you the info to set your max_line_length more precisely. Alternately, have user supply a desired width as a CL argument. ('course then, you'd better check their input for safety too.)

    Either or both are "doable," but add complicatations.
    Duh! I'd forgotten the answer is in the original, so out of curiosity: why do you want to preserve multi-spaces?

    If it's solely for readability that's one thing; if you need the info, is there some good reason not to

    t/\s{2}/~/; t/\r/(something else)/;
    to catch whatever you really need?

    Questions are likely to be IGNORANCE_based