MT-Textile
Textile is a ‘Humane Web Text Generator,’ created by Dean Allen of Textism. After seeing Textile in action, I decided that I must create a Movable Type plugin that does the same thing.
I came to that decision before Movable Type 2.6 and the custom text filter thing were announced. In fact, seeing Textile spurred me to write to Ben about a way for MT users to have more text formatting choices and the option to select them on a per-entry basis. To my delight, he replied that “it’s already in the works.”
So here we are a couple of months later. MT 2.6 is in beta (and very near to release) out and we now have some more choices between “automatic line/paragraph breaks” and nothing at all. Textile is another choice.
Read on for some of the features...
The MT-Textile page has moved here. Please adjust your bookmarks.
I love this plugin so far, but I was just wondering if there's a way to make the formatting syntax NOT show up in RSS and RDF descriptions... ".h1 Blah Blah .bq Quote quote!" looks a little funny.
It looks like the text format stuff isn't done when an excerpt of your entry is generated. You can avoid that problem by either: 1) write a real excerpt for your textile formatted entries. With the time Textile saves, you should have a moment to type up the actual excerpt. 2) don't do abbreviated entries in your RSS feeds. Use the
<MTEntryBody>tag (and<MTEntryMore>too for that matter) instead of <MTEntryExcerpt>.I'll send this info to Ben though. Perhaps it will be fixed in 2.61.
I've said it before, brad, and I'll say it again. You are a mad crazy ninja. I was dreaming that someone would adapt textile for MT, and I even had half a mind to attempt to adapt it myself, but then along comes you, whipping it out before I can even blink. You rock.
Great plugin. However, I've experienced some problems:
I think this is a cool idea for a plugin, though I'm having a couple of problems.
1) Try as I might, I can't get the cite tag to work. It just shows up as double question marks on either side of the text, even in the published entry.
2) I can't get lists to work either. They do seem to work in the MT preview screen, but not in the published entry. Maybe it's something screwy in my css? But HTML-produced numbered and un-numbered lists seem to work fine, I think. Hmm.
You rock with fists of steel.
I get a server-error in "mt.cgi" when rebuilding all...
Plugins work okay, 'cause the load.pl-plugin is giving data. Plugin is installed as mentioned and rights are set. Any idea anyone? TIA!
teeny tiny little nitpick/observation:
The URL discovery code misses a few of the legal top level domains. IANA currently lists, in addition to the ones textile.pm catches: .aero, .coop, .museum, .name, and .pro. While few of these are heavily used, they're all in use. http://mos.boston.museum/ works, for example.
I kinda doubt this needs to be fixed, but I thought I'd point it out in case you're as anal about domain names as I am.
Hey, Brad. Great stuff. One question/comment: if I'm reading correctly, your "bq. " tag does not nest a <p></p> pair inside the <blockquote></blockquote> pair. As a result, it won't validate as XHTML. Any thoughts?
Again, thanks for the great contribution.
I have found, and I think, fixed a problem involving a clash with Smartypants. If smartypants is set to convert "--" to an em dash, this clashes with MT-Textile's rule that converts text between hyphens to text.
So I made a small change in textile.pm, line 177: adding a single dash to the character class [^\s], so that it now reads [^\s-] on both occurences.
I hope this is (a) allowed, (b) legible and (c) useful. I can't get the whol eline to display here, but will send it to you privately if you'd like.
I see that <del> markup doesn't survive. That's what the two hyphens produced before my little workaround.
Hmm, not working for me at all. I'm sure I've got the paths right. Smarty Pants is working. Could there be a permission issue? Am I missing something? Yes, I've upgraded to MT 2.6.
Excellent plugin; it's good to have a simple formatting solution more in line with Wiki text.
One bug report:
The URL wrapper appears too aggressive. In a line with both "Quoted Text" and a "URL":http://www.bradchoate.com/ the anchor appears before the first open-quote, not the one closest to the URL...
Update: Changing the two occurences of
.+in the "text":url regular expression (line 158) to[^"]+fixes it for me. Other REs (like the image tag) will probably have to be tweaked also.Hey! I didn't tell my stupid post to ping you! Why did it do that? Now everybody knows what bonehead I am!
O...
So what would it take to make a BBCode plugin? Anyway you could extend the Textism plugin to insert smiley graphics?
Looks very groovy, but there's a buglet if you try to use Strong or Emphasis at the start or end of a line of text. Try the following test case:
*this is a test*
*this is* a test
this is *a test*
this *is a* test
Apart from that, looks pretty groovy.
I've stumbled across a bug in this plug-in as well. Not sure WHY it happens, just can say that it does.
I upgraded to MT 2.6 and installed this plug-in alongside the already excellent "Smartypants" plug-in I'd been using already. Went into the preferences for MT and enabled it for both the entries and for my comments. Tried to do a full site rebuild and....
... I got an Internal 500 error. A little investigation reveals it only errors when trying to rebuild my individual entries archives. Monthly, Category, and all indexes rebuild just fine. Yet when I do a new entry the individual archive page is created without issue. Turning off text formatting in the preferences allows me to once again re-build all of my individual entries. Turning on Textile in my entries alone and leaving Comments set to line breaks also works, but the moment I tell MT to use Textile on comments it gives me a 500 error when trying to rebuild all of the individual archives.
Don't know why, but I can reproduce it at will. Let me know if you come up with some suggested fixes.
Also, to the person who suggested a UBB Code version of Textile: I think that's an excellent idea and it shouldn't be too difficult to do using a variant on Textile.
Your documentation says that the block formatting codes are a dot and some letters, like '.bq' for blockquotes. Actually, the block formatting codes must be followed by a space to be recognized.
You might want to update your documentation.
A great plugin.
But I would have got it running a lot quicker if there have been a nice prominent comment in the Installation section saying that you have to set the Test Formatting option in the entry (and in the blog setup?) to "Textile".
I spent ages wondering what permissions were wrongly set, before I found that.
It could be mentioned somewhere, either in the MT2.6 user doc or in your release notes, but I managed to completely overlook it and only found it after an hour or two fiddling with the set up!
Aggh - I even proof-read my comment before I posted it. I should have said "Text Formatting", not "test Formatting" of course. Sorry for any confusion...
Any chance of an additional parameter in a later version to allow you to specify the target for a link? I sometimes like to link with target="_blank" so that the linked page opens a new window.
John: personally I hate popups, even if they're not ads. You'll notice that this site doesn't do that at all, so I'm not too keen on adding that to MT-Textile. Having said that, you have the following choices:
This is probably a relative of the bug rodbegbie noted: if a line ends with '--' you get stuck in overstrike mode thereafter.
Love the concept and thanks for writing it -- I look forward to easier blogging!
Hi Brad,
in Germany, it is better to link to a new window, if you are linking to another site - people can sue you for enclosing their content in your frames. So sorry, but I'm sticking with popups as my site is a German domain ;-)
I moded the plugin, which had the nice side effect after rebuilding the site, that the existing links done with Textile each link to a new window!
Thanks again for the plugin - it makes life much easier.
Hi Brad,
in Germany, it is better to link to a new window, if you are linking to another site - people can sue you for enclosing their content in your frames. So sorry, but I'm sticking with popups as my site is a German domain ;-)
I moded the plugin, which had the nice side effect after rebuilding the site, that the existing links done with Textile each link to a new window!
Thanks again for the plugin - it makes life much easier.
I got the plugin and set it up without a hitch. Wonderful, especially for my site, which will have several authors, many of whom know no HTML (and are resistant to learn). Thank you a ton.
My one question is if there is any way to control positioning (align=) or borders or titles on images?
Great plug-in. My only problem is that I frequently use "•" to bullet text, and now that I've installed Textile, it doesn't work any more. Any way around that?
darnit. in the previous comment, i was trying to list the special character coding for bullet, and it showed the the bullet. I was trying to type "& bull ; " without the spaces. anyway, that's no longer working in my mt entries now that I've installed textile.
I have the same problem with —. That's because, as it says in the docs to the plugin, "Also, special characters within your entry text such as <, >, &, international and symbol characters will automatically be escaped into equivalent HTML entities". Is there a way, or will there be, we turn that off?
B'oh. That last sentence is grammatically problematic. You know what I mean.
Chalk up another Internal server error (500) with textile installed. If I have it in my plugins folder I get the error when I try saving an entry.
As soon as I remove textile.pl from my plugins folder, though, the save works fine.
Arg! Brad?
I don't think the Wiki tables are working.
Nevermind!
I would also like to know if/when you intend to fix the RSS/RDF/XML feed bug. It's kind of crazy getting an feed with goofy markup :(
Brad, this is a great piece of code, I'm using it with my own system, not Movable Type, and so far it's doing exactly what I need it to do, with minimal tweaking. ;)
How do I make link with a image? It doesn't work:
"!(imgclass)http://blah/image-thumb.jpg (blah)!":http://blah/image.jpg
Great work! But how do I make link with a image? or a list inside a blockquote? It doesn't work:
"!(imgclass)http://blah/image-thumb.jpg (blah)!":http://blah/image.jpg
Brad,
Your documentation for links is:
"linktext[space](alt)":url.
If you leave in the space, it adds a space to the end of the link. I left it out and it seemed to work fine.
Let me know if there's anything wrong with this approach.
Hi Brad, once again -- wow. Amazing plugin, thank you.
I've been changing a few things around in the .pm file to suit me better but I don't know how to set it so an empty alt="" is put in img tags if no alt text is specified. Suggestions?
Hi Brad- Not sure if you're already aware of this, but here's a minor problem we're having on my site with textile: since anything inside !'s is read as an img tag, if someone types 3 !'s in a row at the end of a sentence(like, REALLY trying to get their point across) then it displays a broken/missing image. If it was just me, I just wouldnt type 3 !'s in a row- but I've got a group blog with 13 authors, and cant count on all of them to remember that. Plus I can't control what commenters type. Is there a fix for this? Thanks!
When I try the "linktext":url shortcut and I want to follow the link with a colon : the colon gets formatted as part of the url, which yields broken links. Try
Putting a space between the url and the colon works of course, but that leaves the space in the displayed blog entry, not good. Making the colon part of the linktext works, but that's kind of ugly as well. Other delimiters work fine such as a full stop or a closing ) bracket.
Is there some trick to signal to the plugin that the url is over and that what follows is normal text?
When I have two formatted chunks in the same paragraph, e.g *some* words and then *some* more - Textile does *some words and then some* - I've noticed this in my comments (have removed sanitize plugin), haven't tried in my main body. Anyone else?
OK, seems to be working fine in my main entries, but this:
Like me, you may have been _desperately_^[1]^ trying
gives me my sup but not my em?
The offending comment described above:
http://nontroppo.org/blog/archives/2002/10/16/predictable.html
Brad,
is there an option when using Textile to make the links open in new windows?
using "linktext":url
Thanks
thanks for this plugin, looks good.
Is there a way of doing <blockquote cite="url"> with textile?
Brad, I'm dithering about upgrading to 1.1 because it seems to have changed the internals of the file. One of the first things I did with 1.0 was to change the "??" tags to output a <span class="myclass"> rather than <cite> tags. Is it possible to make this sort of change in 1.1?
Andrew: I'm not going to change the published behavior of MT-Textile to satisfy the needs of one person. And I'd like it to remain compatible with Dean Allen's Textile syntax as much as possible. So I won't be doing that. However, 1.2 will offer a technique that will allow you to have more control over how MT-Textile behaves. You can accomplish your custom behavior with very little effort (and without having to modify the MT-Textile module yourself).
Oh, sorry. I see I was ambiguous. I wasn't asking _you_ to make that kind of change. I wondered if it was still possible for _me_ to do so: in 1.0, that kind of processing was laid out in a series of regex substitutions which even a non-programmer like me could understand. In 1.1 (I had a quick look) this had been gnarled into a perlism which was much too elegant for me to understand or fiddle with.
1.2 sounds as if it can be made to do exactly what I want. Thank you for all of them, anyway. Even 1.0 has made blogging hugely easier for me. So I realy didn't want to come over sarky and demanding.
Incidentally, one thing I noticed today: a string of the form ??Is this right? Certainly not!?? doesn't seem to get converted by 1.0 -- the '?' in the middle seems to throw it off. I didn't see that in the changelog, so it may not have been reported.
I've been pretty happy about Textile -- thanks again, Brad. Like Ian, I encountered a difficulty with nesting tags -- "blah _blah_ blah":http://www.example.com/ left the underscores in the link text. And like Kai, I regularly want to follow links directly with punctuation. I like the ease of Textile over HTML-by-hand enough that I've just been putting in a space, but I'm not wild about the results visually. If you can think of a syntax to facilitate this that makes you happy, I'd love to see it. (Otherwise, I'll probably do it myself at some point...)
So there's a tiny little bug in Textile 1.1 ... if I bold something like *so* and then later on in the same sentance do it *again* and *again* then my output is:
like <b>so* and then later on in the same sentance do it *again<b> and <b>again*
Not pretty. I changed the regexp from (.+) to (.+?) and it fixed it. Enjoy.
Is there are way or a demand for the == (turn off textism) to work within a paragraph? Currently it only works to set off a complete paragraph (or two or three). Thanks for a fantastic plugin.
GReat plugin, thanks! Attached is a patch which fixes a bug when multiple inline formatting glyphs appear on the same line, like "3^rd^ or 4^th^".
might give this one a try!
Trackback discovery does not work when using Textile formatting. I'm not sure if this is an MT issue or an MT-Textile issue so I am cross-posting this comment here and on the MT Support Forums. Hopefully there is a current workaround or fix.
Thanks
John: Yes, Ben Trott is aware of this issue and it's on his to-do list. In the meantime, I recommend you use regular HTML hyperlinks for links that are trackback enabled.
Would you mind if I attempted to adapt your code into a Perl module?
I'd like to create an HTML::Textile, mainly for my own use in conjunction with HTML::Mason. Basically, I'd like to write all my page content in Textile markup, and have Mason translate it to HTML on the fly.
I assume I'd also need to ask Mr. Allen if I can use the name.
Hi Brad, very nice plugin! Would it be possible to add other syntax like code, quote etc. Something along the lines of the format and syntax of bulletin boards like vBulletin or phpBB.
It seems that !image_url! is not well behaved. When i put two !image_url! at the same line, Textile treats them as one. for example
!http://ooo/pic1.jpg! foobar !http://xxx/pic2.jpg!
is expect to see (pic1) foobar (pic2) but is parsed as "!http://ooo/pic1.jpg! foobar!" and "http://xxx/pic2.jpg!".
If I put the follow line, it works fine. (notice the space before `!')
!http://ooo/pic1.jpg ! foobar !http://xxx/pic2.jpg !
I think rewrite re slightly may solve the problem.
Thanks.
It looks very cool but when I installed it I got a bunch of syntax errors from Perl around the qr{ ... } stuff for URL discovery. What version of Perl does it require?
I installed MT-Textile (MT 2.63). When using it, the preview of an entry works fine and shows all the Textile-formattings, but after saving it, all formattings are gone. And the blog shows my Textile-tagged entry.
What's the problem?
Acronym and caps don't work well for "AT&T", "PG&E", etc... I suggest adding & to the [A-Z0-9] char pattern for both.
Looking at the source code, looks like & is getting changed to & before it gets there, which complicates the pattern slightly.
Suggested patch:
I´ve tryed to make a mailto:name@server.com and i can't make it... i do:
"hola@hola.com":mailto:hola@hola.com
Any solution to this?
Is there a problem with MT 2.64? The block quotes, for which I mainly use Textile, are good, but I tried a Wiki table and this time it didn't work at first. Eventually I got a sort of table, but then the entry, which I had split into two ('More...'), all moved back to the first page.
Thanks for any information.
And I'm a smilie kind of gal. I implemented MT-Textile along with SmartyPants this morning, but it seems that my smilies are now displayed as ":brushmyblades" as opposed to the actual .gif for that command. I would appreciate any ideas you might have for rectifying my much needed smilies in my entries.
Hi, I install your plugin on MT 2.64, but I don't see "Once installed, you’ll see a new “Text Formatting” option available on your weblog configuration (preferences panel) and on the entry edit screen."
Only "Convert Line Breaks on by default: (?) ".
MT and other plugins are feeling well...
Whats wrong?
Hi! I'm learning Perl and as an exercise I tried to correct a problem I had with this amazing plugin: When people put 3 or more "!", textile asumed it was an image. So, I change:
$text =~ s!(^|\s|>)\!(\([A-Za-z0-9_\-]+\))?([^\s\(]+)((\([^\)]+\)|[^\!]+)*)\!(:$urlre)?!$1._repl($repl,_mkimage($ctx,$3,$4,$6,$2))!gem;
to:
$text =~ s!(^|\s|>)\!(\([A-Za-z0-9_\-]+\))?([^\s\(\!]+)((\([^\)]+\)|[^\!]+)*)\!(:$urlre)?!$1._repl($repl,_mkimage($ctx,$3,$4,$6,$2))!gem;
Perhaps it helps somebody. =)
For hlb: Did you check the list of HTML tags allowed in your blog configuration?
Somehow, the conversion of so-called international characters (accents and the like) does not work with Textile.pm in its Blosxom incarnation. All the rest works just fine, but accented characters show up untranslated, which, though I use UTF-8, is not what I want (and Dean's online Textile tool does translate them correctly to numeric HTML equivalents). If anyone has a clue as to how I can get them to work through the plugin, do let me know.
Love Textile and SmartyPants, just got both of them installed and working tonite. Now for the $100,000 question. Is there any way to automatically rebuild all past archives, switching them from 'convert line breaks' to 'textile' in the process?
How do you change the Heading Offset? Right now, they offset to h1 being h3, but I want h1 to be h4. I thought there was a setting for this, but I can't find it.
tamaracks: Yes, there is:
<MTTextileHeadOffset start="n">where n = 1-6. That would be the number you want to use for "h1.". So for you, use<MTTextileHeadOffset start="4">at the top of any template that uses the<MTEntryText>or<MTEntryMore>tags.This looks like fun, but I have two questions before I start using it regularly...
How do I code for a mailto: link? "text":mailto:address@foo.com doesn't work; nor does "text":"mailto:address@foo.com"
And what, if anything, do I need to do to my RSS templates once I've got this running, so that the content comes out right?
Any chance you could add an inline formatting style for us developer-types? How's about using the "&" character, as in: &public void Foo() {}&
Thanks for a great tool! I finally have a weblog authoring solution that I really like (in combination with NewsGator and the MovablePoster plugin).
Any updates on Textile? Just wondering when it'll be heading out of beta... its a great plugin which should come by default with MT as it makes it so much easier to add links. It's much easier for non computer geeks to grasp then html tags.
Any updates on Textile? Just wondering when it'll be heading out of beta... its a great plugin which should come by default with MT as it makes it so much easier to add links. It's much easier for non computer geeks to grasp then html tags.
Running MT2.6 with Textile installed (love it!), I can't get Comments to format correctly ala Textile. I'd rather not remove sanitize altogether -- can you reccommend a template for my sanitize settings that will work with Textile?
In my entries, I often use a DIV with a certain class set to make pull-out quotes.
When I format with Textile, it wraps my DIV in a P tag, and I therefore get an error (document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag) when trying to validate (XHTML 1.0 Trans).
How can I make it so it doesn't wrap my DIV in the P tag?
Thanks!
Hm, I couldn't work out how you prefer bugreports to be filed, so I'll add it here, although it's a minor problem.
It appears that using +text+ doesn't wrap text in <ins>-tags if text contains a html-link. Ie
+Blabla <a href="link">blah</a> blah.+
Will not wrap the text in -tags, like it does at http://www.textism.com/tools/textile/ . Using the Textile-format for links works fine though, so it is no biggie. Keep up the good work.
I have one small suggestion for an excepted case:
/[^0-9]0x[0-9a-fA-F]/, which would be for representing hexadecimal numbers, not dimensions, and thus should keep the 'x' character. Especially since no measurement of dimension is going to start with a zero.Will this plugin be updated to incorporate the new stuff in Textile 2? I especially like being able to do nested lists.