Using Opera to read text/plain

For some time now, I have been using Opera to read large plain-text files, such as RFCs and books, like those available from “Project Gutenberg”:http://www.gutenberg.org/.
Of course, I could have used a normal text reader for this purpose, but Opera has some neat tricks up it’s sleeve, such as the projection mode.


==

One of the little-advertised features of Opera, is the persistent user stylesheet browser.css. I am using this, plus the fact that Opera embeds anything text/plain inside <body><pre> {content} </pre></body>.

==
This allows me to add some rather simplistic CSS, with great effect:
bc. @media projection {
body > pre:first-child {
white-space: -o-pre-wrap;
max-width: 90ex;
font-family: “Bitstream Vera Sans Mono”;
font-size: 1.33em;
margin: 0 auto;
border: 1px solid #ccc;
padding: 1em;
}
}
Create this CSS file and save it as browser.css in the styles directory within your profile directory. Create this directory, if it doesn’t already exist.
Close and reopen Opera. When you now open a plaintext file in Opera, and press F11, the CSS does the following:
# Text is wrapped after approx. 90 characters, if no hard linefeeds exists in the document
# The text is displayed with the wonderful Bitstream Vera Sans font
# The font size is set to 1.33em, which is about 21px with my prefered default 16px font size.
# Further, in projection mode, the text block is centered on the screen (Note that the text _justification_ remains the same as in the original)
# For effect, a border is added.

6 Comments

  1. Sounds like a great idea.
    It does not seem to work with 7.54, though. Looking at the source of a txt-document I cannot find the HTML-elements you are refering to in your CSS…
    best,
    Steffen

  2. This is working just fine in Opera 7.54 here, are you sure you have placed the document in the correct location. In Windows 2000 and XP, the profile directory is usually located at c:\Documents and Settings\{Username}\Application Data\Opera\Opera75\profile, where you substitute {username} with your real username
    bq. Looking at the source of a txt-document I cannot find the HTML-elements you are refering to in your CSS…
    The text documents themselves do not contain any markup, but when Opera displays a document with the text/plain content-type, Opera wraps the text inside a pre element on it’s own.
    You can verify this yourself by opening a plain text document, and type javascript:alert(document.body.innerHTML); in the address bar.

  3. Ah, this was rather brilliant. I’m already using my own stylesheets to format e-mails (mime.css) and such differently than the default, but I hadn’t touched browser.css until now, because I saw no reason to. Now, I definately see a reason, because this improves text reading a great deal!
    Opera rocks. You too, Arve. Great tip. 🙂

  4. Ok, since I use Opera in a single-user-installation, the profile-directory is someplace else (Help -> About Opera helps to find out where).
    Putting the css there makes it work.
    Great thing, thanks.

  5. Just a small thing: You probably meant “<body><pre>{content}</pre></body>” and not “<body><pre></pre> {content} </body>”.

    (As an aside, why do you consider “gmail.com” questionable content in the email address?)

  6. Liorean: Thanks, fixed.
    Of course, GMail should not be considered questionable content. I assume this simply is a matter of blacklist updating gone wrong. Terribly wrong.