(This conversation was moved from discussion. --anarcat)

I've tried to retrieve the wmd-editor source tarball lately, but the site seems offline.

From what I've read on the Internet, wmd-editor is not (yet?) free software by itself, and its author has gone MIA. But it looks like somebody recently took the step to rewrite a wmd-clone under a saner license, see pagedown.

Given all the above, what about upgrading this plugin to use pagedown instead of wmd? It seem a clear win to me...

AFAICS, pagedown is a modified version of WMD. Let's look at its license file: --Joey

A javascript port of Markdown, as used on Stack Overflow
and the rest of Stack Exchange network.

Largely based on showdown.js by John Fraser (Attacklab).

Original Markdown Copyright (c) 2004-2005 John Gruber
  <http://daringfireball.net/projects/markdown/>


Original Showdown code copyright (c) 2007 John Fraser

Modifications and bugfixes (c) 2009 Dana Robinson
Modifications and bugfixes (c) 2009-2011 Stack Exchange Inc.

Permission is hereby granted, free of charge, to any person obtaining a
copy [...]

Ok, so it says it's based on showdown. John Fraser wrote showdown and also WMD, which IIRC was built on top of showdown. (Showdown converts the markdown to html, and WMD adds the editor UI.)

I can nowhere find a actual statement of the copyright of showdown or WMD. http://code.google.com/p/wmd/ has a "MIT License" notice on it, but this is clearly just the license chosen when signing up at google code for the repo that would be used for a rewrite of the code, and the only thing said about the previous 1.0 release of WMD is "use it freely", which is not specific enough to be a grant of license, and is moreover not a free software license, as it does not cover distribution or modification.

Which was all covered in the thread here, when StackOverflow decided to start working on pagedown. http://blog.stackoverflow.com/2008/12/reverse-engineering-the-wmd-editor/ This thread does not give any indication that they ever managed to get a license grant for WMD/showdown. It frankly, does not inspire confidence that the people working on this care about the license.

It would probably be pretty easy to adapt the ikiwiki wmd plugin to use pagedown. But without a clear and credible license, why?

(Note that I have a wmd-new branch in my ikiwiki git repo that uses https://github.com/derobins/wmd, which was an earlier version of pagedown (probably, not entirely clear).)

An alternate alternative is markitup: http://markitup.jaysalvat.com/ It has a clear history and a credible license (MIT or GPL dual license). It's also easily extensible to other formats so could handle rst etc. It does not, however, have a markdown to html converter -- for previewing it has to talk to the server with AJAX. --Joey

Showdown has a pretty explicit license.txt file and it basically looks like a BSD license. That license.txt file was imported into github directly from the upstream showdown source, so it seems credible. That zip file is still available on archive.org, and does mention a BSD copyright.

So Showdown itself is clean: it's free. Nowhere does it say it derives from WMD, or if it does, it doesn't matter because it was made by the same author and then released under that free license. But even then, it does not mention being a derivative of WMD.

I agree the license behind WMD is murky. One the one hand, the google code page mentions the code will be relicensed under MIT but "for now" we can "use it freely":

I'm refactoring the code, and will be releasing WMD under the MIT license soon. For now you can download the most recent release (wmd-1.0.1.zip) and use it freely.

That zip file is again offline, but it's also on archive.org. Things get a little more murky there: the file doesn't actually mention any copyright statement, and the code is actually obfuscated, something that is mentionned on the aforementionned Stack Exchange thread. The terms and conditions of WMD are pretty hostile however:

All rights reserved. You may not duplicate, copy, or reuse any portion of the HTML/CSS, JavaScript, or visual design elements or concepts without express written permission from AttackLab.

But one could argue they apply only to WMD, and not showdown, which has been explicitely published under a different license. And maybe that was the whole point here: the stack exchange people were trying to negociate having the clear and free version of WMD for their own use, maybe showdown is actually what came out of this and what allows Stack exchange to do their thing...

And besides: the point here is that we can't actually use WMD safely, but we can use pagedown safely!.

I tried the plugin: it works, and it works well. It's also fairly trivial to install the upstream showdown library, which is not shipped with the plugin (which alleviates all possible copyright problems). You can take test the plugin at http://testwiki.anarc.at/

There are only three issues I could find during testing:

  1. two previews are showed (the showdown one and the regular ikiwiki one), which can be confusing, but is still necessary because the showdown one doesn't parse ikiwiki directives.
  2. the wiki needs to be rebuilt when the plugin is first activated for the stylesheets to regenerate. new wikis are not affected, and this can be deployed massively on farms without user intervention.
  3. on large pages, the edit screen isn't in the first screen, so it's not obvious we're editing the page, which is also a little confusing - we would need an anchor in there... Update: a simple patch fixes that... but in a rather crude way:

--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -87,7 +87,7 @@ sub genpage ($$) {
        my $actions=0;
        if (length $config{cgiurl}) {
                if (IkiWiki->can("cgi_editpage")) {
-                       $template->param(editurl => cgiurl(do => "edit", page => $page));
+                       $template->param(editurl => cgiurl(do => "edit", page => $page) . '#editcontent');
                        $actions++;
                }
        }
ideally, we would show the edit box next to the page preview... And there's a way to do that too! But it requires some more CSS hackery, like this, for example:

#wmd-preview {
  position: relative;
  margin: 15px auto;
  float: left;
  width: 50%;
}
form {
  position: fixed;
  margin-left: 50%;
}

But this is getting a little crazy and I need to sleep now.

Available in a git repository branch.
Branch: anarcat/pagedown
Author: anarcat

Anyways, let's work on merging that pretty branch already shall we? :) --anarcat