TextBar Drupal module for Markdown and Textile

Michael Geary | Sat, 2005-02-26 12:44
category

Here’s a treat for Drupal users who support the Markdown and Textile input formats on their sites. The TextBar module adds a formatting toolbar for these input formats to Drupal’s content and comment texarea fields.

To try out the TextBar right now, you can comment on this message. (You don’t need to save your comment unless you want to :-) but you’ll be able to try out the toolbar while editing it.)

You can try it with both the Markdown and Textile input formats (and if you select the Filtered HTML format the toolbar will disappear). The Textile input filter is not actually installed on this site, though, because of a conflict between the Markdown and Textile modules. So you won’t be able to actually post a comment in Textile, but you can see how the TextBar generates Textile codes.

The TextBar is not a WYSIWYG editor like htmlArea, FCKeditor, or Xinha. Drupal’s textarea remains a textarea, and the TextBar merely provides a way to enter the Markdown or Textile formatting codes. It’s not as slick as the WYSIWYG editors, but it’s very fast and simple.

If you’ve used the excellent DokuWiki, the TextBar will look very familiar, because that’s what I ported the code from. DokuWiki in turn got it from MediaWiki and phpBB. Many thanks to the authors of these programs for making it so easy to port this code to Drupal.

There are no settings or options in this version. Simply install the textbar module and enable it in the admin/modules panel. Then you should see the toolbar on content body, comment, and block editing pages, but only when the selected input format has either “Markdown” or “Textile” in the name. The toolbar will show and hide itself when you switch between these formats and any other input formats.

There are a number of loose ends. In particular, the internal and external link buttons could use some improvement, and I didn’t implement the image button from DokuWiki’s toolbar. Also, I’d like to move the toolbar right above the textarea field instead of having the “Body: *” or similar text in between. (Not as easy as it sounds.) But it’s useful enough that I thought I’d release this version for comments before submitting it to the Drupal module collection.

At this point, I’ve only tested on Firefox and Internet Explorer. The DokuWiki toolbar does support other browsers, so if I’ve broken something on another browser it should be easy enough to fix.

If you like the TextBar, you can download it here. Your feedback would be greatly appreciated.

Update: I found one bug: If Markdown is the only input format enabled, the TextBar does not show. I’ll fix it shortly. In the meantime, a quick and dirty fix is to change textbar_getInputFormatName() to return either 'Markdown' or 'Textile'.

AttachmentSize
textbar-2005-02-06.tgz21.95 KB
Submitted by davidm (not verified) on Sun, 2005-02-27 18:27.

Hi Michael,

I discovered this Drupal module thanks to one of TextPattern’s forum member, nardo.

Some TextPattern users were looking for textile java toolbar (see this thread on TxP’s forum), so it’s only natural I am quite interrested in TextBar (which I will certainly use for Drupal powered websites projects).

I noticed you release under the GPL, which is nice :) I’ll keep you posted if a port of TextBar is released for TextPattern.

Regards,

David.

Submitted by Michael Geary on Sun, 2005-02-27 20:22.

Thanks, David, I’m glad you like it! It’s funny you mention Textpattern, because next on my to-do list (after fixing some bugs) was to port the TextBar to Textpattern. It seems like it would be a natural.

My immediate need was for a Drupal site I’m running at work, so that came first. But if you don’t get the code ported to Textpattern I’ll probably do it. :-)

I’m curious to see the thread you mentioned in the Textpattern forum, but it seems to be broken. I can get to page 1 of the thread but not page 2.

BTW, I took the liberty of converting your comment from Textile to Markdown syntax. Unfortunately, the Drupal modules for these two formats are incompatible with each other. (Each one has its own version of SmartyPants, both using the same function names!) So for the moment I had to disable one of the formats. But whatever you do, don’t tell Dean that I disabled Textile: This site is hosted on TextDrive! ;-)

Submitted by David (not verified) on Thu, 2005-03-24 00:37.

The thread has been repaired, a problem with images on PunBB 1.1 Now you can see what has come out of the community :-)

hakjoon and tmacwrig have come up with suggestion and experiments of their own, as you will see. But no one has ported it yet, so if it’s not too hard, I guess TxP users will appreciate this coming out with 1.0 final :-)

Submitted by Chris Messina (not verified) on Fri, 2005-05-06 09:58.

Hi Michael,

This is great work—I’m glad to have found it! I’m doing similar work but with more emphasis on the code and making it themeable—replacing all those images with a list of links that can be subbed out with any image you prefer.

See my pre-alpha demo for an idea of where I’m heading.

I’ve also got an AJAX textile live-preview setup that would be great to merge with your textbar!

Again, these are very early prototypes, but I thought you’d find them interesting!

Chris

Submitted by Michael Geary on Thu, 2005-05-12 07:54.

Hey, that is very cool, Chris. The live preview is great. It definitely would be nifty to add that to the TextBar, or maybe go the other way around and build on your editor code to support Markdown and Textile in addition to HTML. Must investigate this more when I get a little time.

Submitted by Anders (not verified) on Mon, 2006-02-20 02:26.

Any plans to update this excellent module for drupal 4.6 and even better 4.7? This module should definately have a place on drupal.org…

Submitted by Michael Geary on Mon, 2006-02-27 12:08.

I have the module working in 4.6, sorry I didn’t post an update—will do that soon. Haven’t tackled 4.7 yet. Also there is a nasty JavaScript error in IE; I’ve been meaning to fix that too. Stay tuned…

Submitted by Visitor (not verified) on Mon, 2006-02-27 19:29.

Great work on this module — I’m hopeful that you’ll find the time to update it for 4.7 because I think it is needed. Not enough emphasis in Drupal IMNSHO on ease of use for non-techies. Sometimes the most interesting modules are the hardest to find. Glad I ran across this one.

Submitted by Rich Pedley (not verified) on Mon, 2006-03-27 10:56.

I relaise that this was written specifically for drupal, but if you are able to give me any hints on how to use this elsehwere I really would appreciate it. I wanted to find a wysiwyg for markdown, but it looks like I am out of luck, however your solution looks to be the closest thing… and I haven’t even tested it!

Submitted by MarcoK (not verified) on Sat, 2008-05-24 06:57.

Hi, i’ve download your script for adapting to another cms. Basically i’d link to execute this scipt in a simple html page.

But it turn some error.

I’ve create a simple page width a textarea and the textbar wrapper div so as a drupal modul that you have included in the .tgz.

Then i’have insert a Implementation of hook_footer.

When i load my page, my js console return these errors:

function textbar_getInputFormatName does not always return a value File sorgente: ./textbar/textbar.js Riga: 342 Codice sorgente: }

have you something to say me to resolve this trouble?

TKS Marco

Submitted by Dominik (not verified) on Sun, 2008-06-15 23:43.

Thanks. I think both quicktags and TextBar are ready to use right now; try them out and see what you think. You can even install them both together—they don’t seem to interfere with each other at all.

Submitted by Visitor (not verified) on Sun, 2008-06-22 17:17.

I’m getting a “file not found” error. Could it be an update is coming?