By chakradeo on
Hi All,
This is my first try to write a drupal module. I have markdown filter module for drupal. This is very heavily based on Jim Riggs textile plugin and Michel Fortin's php-markdown script.
Please give it a shot if you like markdown. I welcome all comments on this module. I am releasing the code under GPL.
http://phpjukebox.sourceforge.net/drupal-markdown/
(till I move it to a more permanent place)
--Amit Chakradeo
Comments
Oops, old version...
Sorry to reply to my own post, but the version on the wesite is older version and will not work drop-in.
Only thing that is different in the new version is the function:
_markdown_process
remove case 2 and for case 1 change it to the following:
case 1:
require_once("markdown.php");
return Markdown($in_text);
The new version also has better help text in the formatting tips page...
I will upload the new version tonight...
--Amit
New Version?
I am interested in testing this module, however it does not look like the "drop-in" version has been uploaded...
Are you planning to add this to the contributed modules section of this site?
It is "drop-in"
You just need to rename the two files (remove .txt) and put them both in modules directory (or markdown subdirectory) and it will just work.
You need to have filter module enabled, though (which I think is default)
Thanks for the tip...Got some issues though...
Got it working now, just got confused by your postin date and the date on the files. Anyway, I am starting to use it and have noticed a few things:
New version...
I fixed some bugs (Thanks grohk for your testing) and uploaded it as
http://phpjukebox.sourceforge.net/drupal-markdown/markdown-module-0.2.tgz
Let me know if you find any more problems...
-Amit
Many Bugs Squashed...But I think I got one still.
Hey Amit, I got the new markdown working very nice, but I am still having issues with automatic linking...It appears that it only works if the stripping of HTML tags is off in filtering. I can't think of a way to add an allowed tag that would fix this, and the position of that filter is locked...The only thing I can think of is changing the markdown syntax in the module to something that does not get filtered..Any other ideas?
You can change the filter order...
Hey Grohk, you can change the filter order by going to /node/admin/system/filters/order
In my site configuration - I see two filters (other than markdown): HTML filtering and Legacy filtering. I do have stripping HTML off, as all my authors are trusted.
I did test the automatic linking and it works fine for me. Infact I did not do any change in the code for it, it has always worked for me.
--Amit
Have you tried...
Auto Links with Strip HTML tags on? That seems to be the problem for me. With that filter on I can't get it to work. It is no problem with strip tags off, but I am wary of that since not all my users can be trusted...
Markdown.php hack ...
You can invent your own way to introduce inline links, but this will go out of standard way of markdown. So I think I will wait for a more elegant way to do that...
Let's say you want to represent inline links with {url}, take a look at
_DoAutoLinks function in markdown.php file and change the preg_replace expression acordingly. (haven't tested this at all)
try it out, might just work ;-)
UTF-8 Issues
Like textile.module, this module passes contents through htmlentities(), which will corrupt UTF8 characters. Use htmlspecialchars() instead: with UTF-8, any entities for insignificant characters (e.g. é for é) are useless.
Pages with Markdown encoding fail XHTML verification...
Textile has this problem too...Here is what I get:
Is there a way around this issue?
Huh ?
Can you describe what is the problem ? Is your site otherwise XHTML compliant ? Can you post the URL ?
The module uses the following character sequence to denote that it is markdown formatted text:
byte \001
"markdown"
byte \061 (ASCII '1')
This should never come out into output text. I am working to improve the module such that it will be possible to enclose markdown formatted text inside tags, and only that text will be processed by markdown plugin. This will allow proper chaining of similar modules.
Looks like the problem is with Taxonomy Context...
http://code0range.net/node/view/265
It appears that the problem is caused by the Taxonomy Context module. It does not run the markdown nodes through the filtering system, and thus does not strip out the special character sequence before displaying the taxonomy navigation menu system on the left.
The menu system is causing other problems with normal XHTML tags too, and I see now that they have some bugs that are similar, so I am thinking that I should submit a bug to that project.
As far as the encapsulation of markdown within tags, I think that is a fantastic idea...Are you going to get a project pages here at the drupal anytime soon? I think Markdown shows the most promise for a user friendly markup system.
And thank you for all your help...I really appreciate it!
I think so too...
Also see how it uses the entire post as the title for the hyperlink..
Regarding getting project pages, I did ask for CVS access, but someone else (Jonas M Luster ) also has a markdown plugin in the works. I asked him for his source code in order to merge the projects, but got no reply yet. I will ping him again. I got the idea of using markdown opening and closing tags from his site.
--Amit
Any progress on the Markdown plugin?
It seems like the best tags to use would be namespaced XHTML, don'tcha think?
like:
<markdown:formatted xmlns:markdown="http://daringfireball.com/projects/markdown">Foobar</markdown:formatted>
I am using the markdown from the sandbox...
http://cvs.drupal.org/viewcvs/contributions/sandbox/jluster/modules/mark...
I killed the non-SGML character tags....But the Help isn't implemented. I think we need to contact Jonas directly maybe. I really like this module, but Jonas' site has a much more advanced version of the plugin than what is in the sandbox.
http://www.jluster.org/
Are there any plans to enable markdown in Comments?
Some of my users have pointed out that the markdown does not work in comments...This feature would make a whole lot more sense.
Speaking of features, I was wondering...I realize that the purpose of markdown is to make things plain text readable, but I wish there was an option to only filter the markdown once and then have drupal store the node or comment or whatever in HTML, like Scoop does with its autoformat. Is this crazy?