MMD to RTF

I may be misunderstanding things but . . .

I’m writing in MMD. If I compile to MMD then all seems to work fine.

However, if I compile MMD to RTF the resulting file has a bunch of HTML code. Not what I was expecting. Is there any way I can go from MMD to RTF so headers get converted to headers, etc.?

I can take my compiled MMD file and run it through Marked to get an RTF in proper condition. But I’m not sure why I need to go through those extra steps when there seems to be a straight MMD to RTF option built into Scrivener.

Is something wrong with my copy of Scrivener? Am I misunderstanding this functionality in Scrivener?

Many thanks in advance for any help you can provide.

Firstly, what version of Scrivener and MMD are you using?

You shouldn’t be seeing any code, but I can’t really offer any advice until I know what system setup you have.

Not in that particular fashion. As documented, the RTF output is meant for quick proofs and such where it does not matter much what the document looks like, or even if it has proper footnotes, figures at all, etc. It depends on what version of MMD you have—for a bit there an experimental XSLT was used, but before and after that, RTF is produced via the UNIX utility, textutil, which just took the XHTML file and did a straight formatting conversion to RTF.

If you want a full-blown word processor output file, use Flat ODT. You might need to upgrade to MMD3 for that; or just download the Scrivener beta, which inclues MMD3.5 (or 3.6) and fully supports the new system.

With .fodt, you should use Nisus Writer Pro or LibreOffice to open the document and from there you can convert it to whatever word processing format you need. That will be fully featured with stylesheets from the top down, proper cross-references, etc.

I’m using Scrivener 2.2.0.5 for the Mac.

I have no idea of what version of MMD I’m using. What’s the easiest way to check this? Somewhere in Scrivener? Elsewhere?

You’re probably using MMD3 then, that’s odd, but maybe you have an old installation that is confusing Scrivener. Try going to your ~/Library/Application Support folder, and if you see a “MultiMarkdown” folder, change the name of it. Do the same check for your system /Library folder.

I downloaded the beta Scrivener suggested.

I tried this suggestion of compiling from MMD to Flat XML (fodt). But that gives me an XML file (natch) that I see now way to convert easily with Nisus. (I can open easily, but how do I convert. I could easily be missing something here.) This may be the best way to go but there must be a step I’m missing about how to convert from FODT within Nisus.

Here’s what I get if I compile MMD to RTF (just giving first few lines):

Mathew Mitchell Website

Last updated: June 21, 2012

[quote] If you want a full-blown word processor output file, use Flat ODT. You might need to upgrade to MMD3 for that; or just download the Scrivener beta, which inclues MMD3.5 (or 3.6) and fully supports the new system.

With .fodt, you should use Nisus Writer Pro or LibreOffice to open the document and from there you can convert it to whatever word processing format you need. That will be fully featured with stylesheets from the top down, proper cross-references, etc.
[/quote]

I changed name from Multimarkdown to Multimarkdown old in user Application Support folder. No such folder in system Library.

Still same problem.

That HTML looks a little odd. MultiMarkdown wouldn’t be putting a BR into the header like that, nor would it use an obsolete version of the BR element. If anything it would be “
”. On the other hand, I note the BR is included in the h1 ID, which is something that MMD would do if it were a part of the title as provided to MMD. For example if your MMD file when compiled straight out instead of using a formatting looks like:

[code]

Mathew Mitchell Website
#[/code]

Then that would cause a result like that. Do you have any raw HTML in the original project? If so, check the validity of it against the HTML5 specification. Easy way to do that is compile to HTML and then run it through the w3c validator.

Potentially, if it isn’t validating it could be messing up textutil to the point where it just outputs raw code. I’ve never seen that happen, but I’m grasping at straws here.

Yes, I have some raw HTML in some parts of the document (certainly not the top part). For example, when I preview the Scrivener project in Marked it shows the top part converted to HTML as:

[code]

Mathew Mitchell Website

Last updated: June 21, 2012

[/code]

So something’s going amiss in the Scrivener conversion. I could definitely have some code that’s causing a problem, but there are no problems when using Byword or Marked. This would be really hard to find (I think)!

On the other hand, I played around with the exported FODT file. Didn’t work as mentioned before, but I then changed extension to ODT and this got converted to Nisus very nicely. As you mentioned, this is probably the best solution as automatic styles are created: saving me a lot of time. Many thanks for this suggestion!

You know, now that you mention it I do recall changing the extension was necessary in getting Nisus to recognise it. Well hopefully that satisfies what you need.

As for Marked previewing the Scrivener file, that really isn’t going to give you an indication of what the compiler will output. Marked takes all of the internal RTF files and reads them manually, using the Scrivener binder file to put them in the right order. If you have the title option turned on, then it will generate its own titles based on the binder names—not the compile names. So for instance if you have the Compiler set to change the titles to “Chapter <$n>” and leave the binder name out entirely, that would not be reflected in Marked.

I’m not sure why you are getting a BR in the title if you can’t see it in the outliner. MMD will insert a “
” if you leave two empty spaces on the end of the line, but never a “
”, and I’m not even sure if that works in the title field anyway. I’ve tested with TextMate and it appears to ignore all whitespace on the title line.

What does the MMD line look like for that title, coming out of Scrivener?

Here’s what it looks like with straight export to MMD:

Base Header Level: 1

Mathew Mitchell Website

Last updated: June 21, 2012

Professional Overview [overview]

Okay, first off I have no idea where the ‘
’ stuff is coming from. The only way I can get a result like that is if I type it into the editor itself, but then if I do that I can see it in Marked’s HTML preview as well. I’d check invisible characters and make nothing strange is going on. Lines should end with the pilcrow symbol only.

As for the primary error, it has to do with your meta-data. It looks like Fletcher’s RTF script is set up to assume you are creating a whole document, not a snippet. When you omit the Title and Author meta-data fields, MMD uses “snippet” mode—that is it doesn’t create an entire web page, just the raw HTML that would go inside of the BODY element. This way you can paste output into an existing boilerplate if need be. For RTF though, it assumes you are creating an entire web page out of the file, and textutil appears to be incapable of handling non-complete web pages for conversion to RTF.

Just add a Title and Author meta-data key set to your compile settings and you should be okay. The
stuff might cause issues for you depending on what you do, so you might wish to continue investigating what happened there if things stop working

Thanks so much for your help!

I finally discovered the source of the weird
issue. At some point in the distant past I had used the project replacement feature that would turn three or four spaces into a
. I have no idea why I did this as it was done over a year ago. At any rate, removing that wacky thing also removed the problem.

Then I did what you suggested regarding meta-data and that also worked.

Oddly, the biggest thing I got from all of this is to compile to FODT and then change extension to ODT and then import into Nisus. This is exactly the ideal export for me as styles are exported as well. I really appreciate this!

Many thanks for your persistence and help on this issue.

Ah ha! Replacements. That explains why Marked didn’t see them either.

But yeah, just so you know, two empty spaces on the end of a line, followed by a line that is adjacent will insert a “
”, so if you do need them, that’s a handy way to generate them.

Definitely! That’s the way to go with MMD now, if you need a word processor file. The RTF thing was always a very poor way of going, to the point where some people even compiled as .tex and then used the UNIX latex2rtf script. But this new method neatly plugs what was one of the major gaps in the MMD workflow: getting to a normal Word workflow and the rest of the universe. I’m glad that Nisus can handle this because LibreOffice is a big clunker.

Now, for figuring out MMD to e-books! One of these days.

Ha! MMD to e-books was going to be my next forum question. I’ll try to be patient! But, seriously, MMD to e-books within Scrivener would be fantastic.