Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I LOVE TextEdit. It works exactly as I want for creative writing. I normally save as RTF, but sometimes a simple well-formed HTML file could be useful – one with just text and h1's, h2's, etc.

But when I save as HTML in TextEdit, it contains a lot of junk – though better than MS Word.

Is there an OS X rich text editor that saves pretty HTML, or a convertor (commandline or otherwise) that will take TextEdit's RTFs and turn them into pretty HTML?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I'd recommend learning Markdown and using a text-editor that can output to HTML. Try JDarkRoom. It's a full-screen, distraction-free text editor that can export to simple HTML if you use Markdown to write.

It's not an RTF editor nor an HTML editor but you can bold text by enclosing them in "**", among other things. Here's a quick look at how Markdown works:

Typing **ham** gives you <strong>ham</strong> which displays ham
Typing _ham_ gives you <em>ham</em> which displays ham.

Ham
---
gives you <h2>Ham</h2> or:

Ham

The comments system here in StackExchange uses Markdown (just click the pink ? for some basic info). Or you could give it a try here: http://johnmacfarlane.net/pandoc/try

When you type in JDarkroom, you'll be typing in plain text but you can export your content to HTML. No extra markup, inline styles or classes. Just simple HTML. And you can switch it to full-screen mode (might help get your creative juices flowing).

Here's how it looks. enter image description here

share|improve this answer

It's probably not the kind of perfect answer. As far as I'm concerned, there are not many ways to get HTML out of RTF on OS X without writing your own code.

Using Cocoa HTML writer

There's no need for any text editor. OS X has this built in: textutil:

textutil -convert html your_rtf_file.rtf

This will create an HTML file with the same name. For example, this RTF file:

enter image description here

is converted into the following HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.35">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
  </style>
</head>
<body>
<p class="p1"><b>Bold Text</b></p>
<p class="p2"><b></b><br></p>
<p class="p1"><b><i>Italic and Bold</i></b></p>
<p class="p2"><b><i></i></b><br></p>
<p class="p1"><i>Italic</i></p>
<p class="p2"><i></i><br></p>
<p class="p1">Normal Text</p>
</body>
</html>

If that is "junk" is a good question. But that's just what the RTF file really contains. You can't strip out anything from the HTML without losing information. In the above HTML code, what would you remove? (maybe apart from the class attributes)

Using RTF2HTML

RTF2HTML one's is written for OS X and provides you with a view to enter RTF text and shows you the resulting HTML code right away.

enter image description here

But as you can see this generates even more "junk".

Alternative: Use Markdown

If you can adapt to such a workflow, Markdown comes in very handy when you want to convert text with minimal formatting to any kind of output. The syntax is the same as used here on Super User. In its basic form, it outputs HTML. Using MultiMarkdown you can even output to more formats. Its website offers an installer for OS X.

share|improve this answer
1  
An easy way to convert selected Markdown text to HTML would be to use the MultiMarkdown to HTML service in Markdown Service Tools - Brett Terpstra. –  Lri May 22 '11 at 21:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.