Improved plain-text handling in Firefox

8 March, 2013 § 30 Comments

If you’ve ever tried to read a plain-text file in Firefox, you may have noticed that we didn’t have an option to apply word wrapping to the text. New in today’s Firefox Nightly build, we are now applying word wrap to plain text documents by default.

For example, this file is very hard to read when the lines aren’t wrapped. The lines scroll offscreen horizontally, and the user has to use the horizontal scrollbar on the bottom of the screen to read the file (yuck!). Here’s a screenshot of what I’m talking about:

Long lines are not wrapped

Long lines are not wrapped

With word wrapping applied, the text is much easier to read and the line length will adapt to the size of the browser window:

With long lines wrapped

With long lines wrapped

Some documents aren’t ideal for word wrapping, and to aid that we have made it easy to disable the feature. To toggle whether the document is wrapped on a case-by-case basis, you can change between the “Wrap Long Lines” stylesheet and “No Style”.

Toggle word wrap

If you’d like to disable the feature entirely, you can go to about:config and set the plain_text.wrap_long_lines preference to false.

Tagged: , ,

§ 30 Responses to Improved plain-text handling in Firefox

  • stephendw says:

    We can’t have the thousands of text files on our website wrap. Is there a way to insert a directive (like in an .htaccess file) so that all browsers do not wrap the text?

    • msujaws says:

      Can you try changing the mime-type of the text files to text/html? Let me know if that doesn’t work for you.

    • stephendw says:

      Thank you for the suggestion. That doesn’t seem to work though. I also tried text/plain and text/rtf mime-types. Hope there is a solution! Any other ideas?

    • msujaws says:

      I tried some mime types and saw the same result you got. text/html won’t work because HTML documents will by default text-wrap their contents as well.

      It seems you may need to wrap your content with “pre” tags in order to tell the browser that this is preformatted text and to not wrap.

    • stephendw says:

      Yes, content must be wrapped with something, but I just couldn’t edit thousands of files. Here is the solution I finally employed.
      In .htaccess: RedirectMatch (.*)\.txt$ textdisplay.php?file=$1.txt.
      In the .php file, inside

      : echo file_get_contents("$_GET['file']); It's a solution at least.  Word wrapping is not a Firefox specific thing.  All major browsers are wrapping text these day, so thanks for indulging me!
    • stephendw says:

      Here is the solution again, in case anyone needs it, for disabling word wrap using htaccess and php, since my earlier comment did not format correctly: In .htaccess: RedirectMatch (.*)\.txt$ textdisplay.php?file=$1.txt In the .php file, inside a “pre” tag: echo file_get_contents(“$_GET[‘file’]);

  • stephendw says:

    Oops, wish I could edit my last comment. Looks like comments pay attention to “pre” tags!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading Improved plain-text handling in Firefox at JAWS.


%d bloggers like this: