Mellel to MultiMarkdown

I’ve spent the wee hours of the morning writing a simple Mellel-to-MultiMarkdown converter, which you can download from my website:

http://wwwuser.gwdg.de/~mrosena/mellel2mmd.zip

The archive contains the converter mellel2mmd.xsl a test document test.mellel and a Platypus Droplet. The converter is not fully functional yet, but it already has some advantages over importing RTF files from Mellel. YMMD, of course.

I haven’t used Mellel before, so I haven’t tested it, but I have linked to it on the MMD site. Thanks for releasing this!

I’ve updated the converter on my website:

wwwuser.gwdg.de/~mrosena/mellel2mmd.zip

Supported MMD Elements:

  • MMD Metadata (via Mellel’s Document Info menu)
  • headers
  • emphasis
  • footnotes
  • blockquotes (paragraph style must be ‘Blockquote’)
  • code spans (character style must be ‘Codespan’)
  • preformatted code blocks (paragraph style must be ‘Code Block’)
  • lists
  • citations
  • figures
  • tables (doesn’t work for all kinds of tables)
  • captions

I have included a new sample document, test.mellel, that demonstrates all the features. Dragging it on the Mellel2MMD droplet should produce a valid MultiMarkdown file.

There’s a new version of mellel2mmd on my website, that comes with a special version for Scrivener. The new converter does now preserve footnotes and annotations (i.e. the second note stream in Mellel). 8)

thank you stranger for mellel to mmd!

i downloaded it yesterday but it kept giving an error when i tried to drop a melel doc onto it. although the window closed very quickly, i think the error was

cant find \main.html

or something very close to that.

have i installed it incorrectly?

thanks very much for your help.

–df

Sorry for the trouble with mellel2mmd. I’ve only tested it on two machines so far, so it may well be that I’ve made some stupid mistake in the bash script. :blush: main.xml is the actual document inside your .mellel package. There’s obviously something wrong with the path if it can’t be found, but I have no idea what :cry:

As a last resort you could run mellel2mmd from the command line. Unzip mellel2mmd on your desktop, open the terminal and try

cd Desktop/mellel2mmd xsltproc -o test.txt mellel2mmd.xsl test.mellel/main.xml
That should produce a Markdown file named test.txt from test.mellel.

If you find this to complicated you can use Stephen Still’s Mellel XSLT Export Runner from the Mellel forum. Just select my mellel2mmd.xsl instead of his mellel2html.xsl file. Note that this is not the special XSLT file for Scrivener. That one is buried in the Contents/Resources folder inside the “Mellel2MMD (Srivener)” bundle (right-click, open package…).

BTW: Is anyone here familiar with Platypus? Fletcher? Amber? The bash script looks currently like this:

#!/bin/bash new=`echo "$2" | sed s/mellel$/mmd/g` xsltproc -o "$new" "$1/Contents/Resources/mellel2mmd.xsl" "$2/main.xml"

thanks for this. i will try it out this afternoon.

it could also be that i have put the mellel app in a weird place - my copy is in a file called Mellel in the applications folder. perhaps mellel2mmd expects it to be somewhere else. also i put mellel2mmd in a folder of the same name, also in the apps folder.

did i accidentally break an important symmetry? :wink:

regards

df

PS i am v curious how outlines versus document sections/headings come out differently in mmd and ultimately scriv!

No, this is not your fault. The Droplet doesn’t even need Mellel.app to work (well… it doesn’t seem to work at all, but theoretically…). It depends on a command line utility that comes with Apple’s Safari browser.

results: the export runner worked well and produced mmd results that were importable into Scriv.

i have attached a pdf of the results - which were compiled out of scriv. (the result was an rtf file which was printed to pdf)

you can see that all of the beautiful headings and doc structure in your test mellel doc seem to have been lost, but this could easily be due to operator error on my part!

what do you think, should the scriv results have been more structured?

kind regards,

df
compiled_test.pdf (23.8 KB)

further note:

for your test mellel file, the converter works ok and produces scriv compatible mmd output.

for my own mellel files, i get something unusable that looks like this:

<variable#4>
<variable#5>
<variable#6>
<variable#7>
<variable#8>
<variable#9>
<variable#10>
<variable#11>
<variable#12>
<variable#13>
<variable#14>
<variable#15>
<variable#16>
<variable#17>
<variable#18>
<variable#19>
<variable#20>

text text…

obviously, i must be doing something wrong here. pointers?

thanks for your help.

kind regards,

df

No, this looks ok to me. MultiMarkdown is only a plain text format that has no concept of sectioning fonts, etc. Scrivener imports only the structure/outline of an MMD document, so your binder in Scrivener should look like this:
Bild 1.png

All other relevant information is still there, but it is preserved in MMD syntax, which Scrivener itself does not interpret. Note that MMD is not just a file format, it’s also a Perl program that reads this format and transforms it into XHTML. The XHTML can in turn be transformed into something else like RTF, LaTeX or HTML.

I have attached a PDF file that was created from the same test.mellel document as yours. The only difference is that I used “MultiMarkdown -> LaTeX” to compile the draft. I can make my LaTeX setup available to you, but it requires an installation of MacTeX and a good working knowledge of LaTeX and friends to use it.
test.pdf (66.6 KB)

Yep, that’s a bug. I’ve already tried to fix it in the latest version.

tried the new version and the etc stuff is gone.

now the o/p is an accurate text file of what was in the mellel doc. the text seems ok, but the resulting file doesnt look like an mmd file. did i miss a step?

thanks v much for your cool util.!

regards,

df
results.png

Can you send me both files, the Mellel document and the MMD export (preferably in a .zip archive)? My mail address can be found at the bottom of my website.

they are on their way to you!

thanks and regards,

df

I think I’ve solved the puzzle. :slight_smile: You were using Mellel’s compressed file format. I’ve updated the script on my website to give out a warning when that happens.

hi there,

unchecked “compressed file” saving mellel and tried again using a list file in the form of an outline. for good measure, i tried both of your mmd xsl’s. they produced identical output! neither of the files was an mmd file that scriv would accept, they looked like this:
outline_mmd_export.png

what would really be cool was if there was a way to make outlines in mellel that would come out as thought the outline heading were auto-titles. this would probably give the right results in the melle2mmd converter.

after all, the mellel outline is just text. you would expect it to come out just as text in an mmd file. a mellel text with autotitles/section titles, would probably come out the right way in an mmd file .

mellel should really allow you to create outlines/autotitles easiy. that is really my current issue.

thanks for your help

be well

df

Yep, this behaviour is intended. The list in your example is a valid Markdown list and would produce a proper HTML or LaTeX document. You can easily verify this with one the various testbeds for Markdown and its dialects:

daringfireball.net/projects/markdown/dingus
michelf.com/projects/php-markdow … babelmark/

After all, the mellel2mmd converter has to satisfy the MultiMarkdown program. What you really want is a converter for Mellel-lists to Markdown-sections. I guess I could rewrite the converter to do that, but it’s actually a lot easier to use grep or sed to transform your markdown lists.

you are not wrong!

if i were better at grep, this would probably be v easy…

as it is i am just gettging to grips with it. if i knew the right expression for an arbitrary sequence of words/text before a it would be much easier. then i could search for the title of my heading/outline item and put “#'s” around it.

sorry for being so green and thanks for your help.

regards,

df