Opening txt files in Chrome

9,616 views
Skip to first unread message

Sharath

unread,
Aug 24, 2010, 9:22:37 PM8/24/10
to Chromium-extensions
Hi All,
Why does chrome word-wrap a txt file automatically ? Is there
a fix to avoid this ?

-Sharath

Ben

unread,
Aug 24, 2010, 10:55:20 PM8/24/10
to Sharath, Chromium-extensions

It seems Chrome converts text files into simple html files, with text
wrapped in <pre> tags. While this makes formatting the files simple, it
also constricts the formatting of the text to what you can specify in
CSS.

If Webkit supported the text-wrap CSS property, I could easily create an
extension which set all elements (or even just <pre> elements) in text
files to 'text-wrap: none', which would keep all lines from wrapping.
Unfortunately, it seems like no browser currently supports text-wrap, so
there's no easy fix (at least, none that I'm aware of).

--
Ben

Sharath R

unread,
Aug 25, 2010, 12:33:39 AM8/25/10
to benj...@gmail.com, Chromium-extensions
oops.. thanks for the reply Ben.. in tht case, can i open a text file with notepad or someother application from chrome ?
--
Regards
Sharath

Ben

unread,
Aug 25, 2010, 1:08:40 PM8/25/10
to Sharath R, Chromium-extensions
On Tue, 2010-08-24 at 21:33 -0700, Sharath R wrote:
> oops.. thanks for the reply Ben.. in tht case, can i open a text file
> with notepad or someother application from chrome ?

If you can set an application to be the default for text files (for
instance, I think you can right click a text file on Windows, click
'Open With...', and there may be a checkbox you can click to make the
application you choose the default. I'm pretty sure you can do that on
Ubuntu (in Gnome, maybe KDE) too.

If you can't do that, you may have to install an application which does
this for you, or an extension with an NPAPI plugin (but I don't know if
one exists with this functionality), or edit the Windows registry
directly (but I don't recommend that).

--
Ben

PhistucK

unread,
Aug 26, 2010, 2:37:18 AM8/26/10
to benj...@gmail.com, Sharath R, Chromium-extensions
Actually, "white-space: pre;" is supposed to fix it.
The problem is that Chrome\WebKit automatically add these style definitions to the "<pre>" element in text files -
word-wrap: break-word; white-space: pre-wrap;
Which cause the text to wrap.
If you remove these definitions (a simple unchecking them in the Developer Tools), the text will not wrap.
Unfortunately, you will have to do this everytime you open a text file in Chrome (or create a content script that clears up the "style" attribute of the (only) "pre" tag in the page.

☆PhistucK



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


PAEz

unread,
Aug 27, 2010, 2:45:34 AM8/27/10
to Chromium-extensions
If your on windows then this might interest you......
http://members.iinet.net.au/~bertdb/ryan/ViewSourceWith/help.html
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .
Reply all
Reply to author
Forward
0 new messages