# I made a Markdown editor plugin for Q2A - thoughts/suggestions?

12.0k views
in Plugins
edited

UPDATE: check this thread for future updates.

I've been working on this on and off (mostly off), for a few months now. Finally I got round to finishing it to a reasonable state! It's a Markdown editor plugin, which has several advantages over CKeditor, the default in Q2A.

More details on the plugin, instructions and files to download are available here: http://codelair.co.uk/2011/markdown-editor-plugin-q2a/

It's licensed under GPL so it's free and open source. There are some minor bugs that I haven't managed to fix just yet, so if anyone manages to fix them please let me know and I will update it. Also, I have copied the files direct from my Q2A site where it's been in use for the last little while, so if there turns out to be any site-specific code that I left in there let me know ;)

I'd love to know what you think, and any suggestions for improvements! Just post an answer here.

edited
Dear @Scott have you tried to combine your plugin with MathJax? I mean editor preview generates also mathjax fonts as typing. Thanks
by
I haven't tested the new plugin  yet but I had a previous one that was quite nice. I hope in the new updated plugin if you can allow mathjax to be updated during preview mode and to allow its special characters such as backslash, \, single qoute', underscore _.
Just tested this on my QA site. Works nicely and just what I wanted! Very StackOverflow-esque. Thanks!
Thanks for your work! It works well on my site. Anyway, I want to know how to make it support in comment? is this simple?

by
Wow, Markdown plugin really has sense for me! Definitely I test it and I'm interested in father development.

I think we need simple WYSIWYG editor  with markdown like one at StackOverflow.
by

I have problem

by
version
1.4
1.4.1
You should read instructions before installing plugin. (2. step - Copy the CSS from sample.css to the bottom of your theme’s current stylesheet.)
by
Yep, that's what it looks like for me if I turn off CSS. So make sure to copy the CSS from sample.css to your qa-styles.css.
by
Oops, Sorry =[
thank you:)
"Open entered links in a new window:" feature doesn't work with Markdown editor.
by
What do you mean? Where is this option, in Q2A somewhere?
admin/viewing >> "Open entered links in a new window:"
by
OK I will take a look at this and see how to detect this option. The links currently get put through a native Q2A function so I thought that would take care of everything, but maybe not.
by
a temporary solution is to open:
qa-plugin\markdown-editor\inc.markdown.php

navigate to line 608 that contains:
$result .= ">$link_text</a>";

and replace it with:
$result .= "target=\"_blank\">$link_text</a>";

Hope this helps.
Thanks, it works :)
+1 vote
by
I left some comments on the project page, but I'll cross-post them here too.  Great plugin!  Thanks alot.  Much preferred over the wysiwyg editor.

Just one complaint, that 'top' should be changed to 'window' in the javascript, otherwise it breaks if q2a is running in an iframe.
by
edited by
I've replace text in the file markdown.min.js
...addEvent(windows,"load"... and it works fine in frame

UPD: well I'm also replace some other "top" to "window" in files markdown.min.js and in wmd.js
by
One complaint I have with the markdown js (not your plugin) is that when you quote text, it truncates it all, making it quite difficult to read.  Today I managed to "fix" this, by removing the following command from markdown.min.js:

f.wrap(a,d.wmd_env.lineLength-2),

or from wmd.js:

command.wrap(chunk, wmd.wmd_env.lineLength - 2);

Now it just adds quote marks to the beginning, as seems reasonable.
+1 vote
Thanks DisgruntledGoat for this wonderful plugin.

I saw this plugin working on your site, Can I use this pulgin for Q2A 1.4.2?

also will it show preview box? similar to what I can see on your site.

Is this plugin works on the custom created pages?
by
Yes, it works fine on 1.4 and it comes with the preview box. Make sure you copy the CSS from sample.css to your stylesheet for everything to display properly.
It doesn't work on custom pages, they just use a plain text box. I don't think there is any option to use a different editor, not even the WYSIWYG one.
Thanks! what changes does it make to database?
by
It doesn't make any changes at all. New posts made with the editor will have the type "markdown" in the database. There is a SQL query in the readme on github ( https://github.com/svivian/q2a-markdown-editor ) that will change the type of all old posts to markdown if you want that. It's not part of the plugin because it could break older posts.
Thanks again!