RTF to MD extravaganza

Scrivener is RTF-based, and yet it does have an MMD module (which works nicely). I know this is probably not easily attainable, I haven’t found much on the Web on this, but I guess it doesn’t cost much asking: would it be possible to have Scrivener convert a RTF file into markdown?

If not, why not?


p.s. I don’t write code, but it doesn’t seem to me an insurmountable task. And yet, I haven’t found a good RTF to markdown converter on the web.

Mainly, there isn’t much demand for it, especially in a program like Scrivener where people are generating new content from scratch. If you are going to be using M/MD for that, you’d type it in from the very start, and in fact many people using it are coming from plain-text platforms like iOS where using MD is really the only good way to “format” text. Most people prefer to write in simplified markup for its elegance, ease of use and portability, but they aren’t looking to convert word processor files into it.

As for if we’ll ever include something like this: maybe. There was more hope for it when iOS was so completely devoid of options that it almost looked as though Markdown would be the only solution for it, then a complete round-trip conversion would be necessary for most people. However iOS 7 has introduced native RTF parsing (finally), so I’m not sure what the status is on that project. It’s priority has doubtlessly been dumped to “maybe if we have time”. Keith only has so much of it, after all. :slight_smile:

yeah, i can see that it’s a niche kind of need. that explains its absence also outside scrivener. makes sense

One reason why there are few (actually I doubt there are any) ways to convert RTF to Markdown or Multimarkdown, is that RTF is considerably richer than MMD. There are only a few things you can style in MMD. This was its intention from the beginnings of markdown: to provide a very simple, stripped-down way to mark text in a way that John Gruber, the format’s creator, could parse into HTML.

Not all HTML is supported in Multimarkdown, and RTF supports a lot of things that HTML does not.

As a result, any RTF to MMD converters would lose a lot of formatting that the original text had. And they would annoy and frustrate non-technical writers who did not understand the limitations of markup languages.

In brief, this is what any such converter would have to do:

  1. take the RTF and translate it into HTML, as far as HTMl can describe the document at hand.
  2. translate what HTML markup could be expressed in MMD, as MMD, while leaving all the rest of the HTML intact (since MMD simply passes HTML markup through without touching it)

what the document author would end up with is a document, part-MMD, mostly HTML, that would not suffice as raw HTML – that is, a browser would not render it properly and an HTML editor would be unable to digest it – and at the same time would not satisfy the clean, simple requirements of MMD writers.

If you have an RTF document, and wish to get MMD out of it, you should save the document as HTML (several programs do this quite well) and then get to work on stripping out all formatting that MMD does not support, using a text editor, whilst changing all the formatting that MMD does support into MMD format. This can be done with a text editor and would take about a quarter-hour once you get the hang of it and know what you are doing. You will, of course, in the process lose all the formatting that MMD does not support. (About the quickest way to accomplish this is: (a) save the RTF as HTML, (b) open the html file with the Firefox browser, © from Firefox, Save the file as text, (d) open the text file in a text editor and make the half-dozen or so changes to conform to MMD.)

  • asotir

What do you know? Just today IA Writer for Mac has been updated with the new feature of importing .docx files and converting them to .md

It’s a little buggy, but for a first release, it’s not too bad

And yes, I realize that RTF and MMD are quite different and it’d be laborious to have a good conversion of a complex file. In some limited cases, though, having an automatic way of converting a fairly simple .rtf or .doc file into .md is useful to me. Looks like IA Writer for Mac helps!

Good on you for finding IAWriter – hope it works as you wish.

Looking into this a bit more and running a test, I find that Scrivener could be used for this purpose fairly simply. Not so simple as clicking a button, but you could set up a special conversion project with the compile settings all arranged as needed. Then drag a RTF file into the binder, Format - Convert - Italics and Bold to Markdown Format, split and arrange folders and levels (to make sure your headers come out at the right level) and set your compile to Multimarkdown. You will also need to make sure that the formatting is right for Title and or Text of your documents and folders, and one more trick: in Replacements in the Compile settings, replace one carriage return with two (on the Mac, replace Option-Return with 2 of them).

There may still be some tweaking needed if you have lists, but once you have the compile settings done and you get the hang of it, a novel could be translated in this way in about a quarter of an hour.

– asotir

Excellent! Thanks a lot. I’ll try this strategy when I have time and/or the need. The IA Writer conversion is OK but limited. This sounds much more flexible and powerful

In the spirit of this thread, I’d like to mention a simple script that I’ve found profoundly useful for stripping HTML coding to produce a base markdown text file. Go to this URL:


I use the current versions (Nov 2013) of Firefox on Linux and Windows, and TenFourFox on my Macs (PPC, OSX 10.4.11). As per the author of the script, I invoked a new bookmark and pasted the script into the URL portion. It works on all three OS/machines.

When I come to a webpage I wish to retain, I invoke the ‘make.text’ bookmark, and a new browser window pops up containing the markdown-coded text, ready for saving as a file. I typically use a text editor to strip out all the extraneous header, sidebar, and footer content, which might take me 30 to 60 seconds, until I have the base document.

Opening the foo.md text document in a free software app such as ReText will show a nicely formatted document as if it had been composed in Word or Bean or …

So anytime I wind up with an RTF or HTML doc I want to ‘reduce’ I use make.text, the quick & simple browser bookmark tool.