SyntaxHighlighter for Movable Type allows you to easily post syntax highlighted code all without loosing it’s formatting or making an manual changes on Movable Type 4 powered by SyntaxHighlighter 2.0.
Download †
- version 0.1.1 (2009/10/04 updated)
- mt-SyntaxHighlighter_0.1.1.0910040.zip(within syntaxhighlighter 2.0.320)
- version 0.1.0 (2009/03/05 updated)
- mt-SyntaxHighlighter_0.1.0.090305.zip (within syntaxhighlighter 2.0.296)
Functions and Limitations †
This plugin has the following functions.
- Added one tempalte tag and two text filters
- Install SyntaxHighlighter 2.0 to mt-static
- Use tempate tag instead of includeing css and javascript on html header
- Write raw source code in entry by using text filter
- Supported php dynamic publishing!
It also has the following problems oppositely.
- The entry dosen’t other text filter (ex. rich text editor)
- It is not supporeted the configuration of the SyntaxHighlighter
- Required Movable Type 4 (I have tested with 4.2x, 4.3x and 5.0beta)
How to Use †
1. Download this plugin and copy to your mt directory. †
2. Add MTSyntaxHighlighterInclude tag to “HTML Header” tempates. †
The MTSyntaxHighlighterInclude has brush and theme attributes. The brush attribute is required and the theme attribute is optional.
| attribute | SyntaxHighlighter 2.0 |
| brush | as3, csharp, cpp, css, delphi, diff, groovy, jscript, perl, java, php, plain, powershell , python, ruby, scala, sql, vb, xml(Use CSV) |
| theme | default, django, emacs,fadetogrey,midnight, rdark |
3. Create an Entry †
Select “SyntaxHighlighter” or “SyntaxHighlighter + Convert Line Breaks” as Format
Write source code as following format:
[code:language] source code [/code]
language is supported in Brush aliases.
| language | Brush name | File name |
| as3,actionscript3 | ActionScript3 | shBrushAS3.js |
| bash, shell | Bash/shell | shBrushBash.js |
| c-sharp, csharp | C# | shBrushCSharp.js |
| cpp, c | C++ | shBrushCpp.js |
| css | CSS | shBrushCss.js |
| delphi, pas, pascal | Delphi | shBrushDelphi.js |
| diff, patch | Diff | shBrushDiff.js |
| groovy | Groovy | shBrushGroovy.js |
| js, jscript, javascript | JavaScript | shBrushJScript.js |
| java | Java | shBrushJava.js |
| jfx, javafx | JavaFX | shBrushJava.js |
| perl, pl | Perl | shBrushPerl.js |
| php | PHP | shBrushPhp.js |
| plain, text | Plain Text | shBrushPlain.js |
| ps, powershell | PowerShell | shBrushPowerShell.js |
| py, python | Python | shBrushPython.js |
| rails, ror, ruby | Ruby | shBrushRuby.js |
| scala | Scala | shBrushScala.js |
| sql | SQL | shBrushSql.js |
| vb, vbnet | Visual Basic | shBrushVb.js |
| xml, xhtml, xslt, html, xhtml | XML | shBrushXml.js |
After publishing, the entry is displayed.
(When theme attributes is “emacs” )
If you have already used the syntaxhighlighter 1.5 †
The syntaxhighlighter 2.0 changed the target html tag from version 1.5. You have to set “compatible with 1.5″ in settings.
See also: http://alexgorbatchev.com/wiki/SyntaxHighlighter:Upgrading
License †
SyntaxHighlighter for Movable Type. Copyright (C) 2009 makoto_kw ( http://www.makotokw.com )
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
SyntaxHighlighter is licenced under LGPL 3. Copyright (C) 2004-2009 Alex Gorbatchev.
SyntaxHighlighter is donationware. If you are using SyntaxHighlighter 2.0 on your site or including it in your product, please donate.





“Download this plugin and copy to your mt directory”
What, exactly, does “your mt directory” mean? And what does “copy” mean? am I supposed to unzip the contents, or just drop the .zip file in? If the former, do I need to distribute the contents of the mt-static subdirectory into my mt-static directory, etc.? Please be as specific as possible.
Thank you!
Looks from what I did that what I really need to do is unzip the file, and then
rsync -av mt-SyntaxHighlighter*/ /Library/WebServer/MovableType/
Maybe by “copy” you meant, “in Windows explorer, drag the contents of the .zip file and drop them on your mt directory,” but that strange “directory hierarchy merging” behavior is completely windows-specific.
…and then, that’s only going to work because my mt-static folder is a subdirectory of what I think is “my mt directory” (/Library/WebServer/MovableType/), which isn’t a foregone conclusion based on the installation instructions I’ve seen out there on the web.
Okay, this is pretty cool! But what is the markup syntax aside from
? Is it markdown syntax? Do I need to write in HTML aside from the
“tags?”
@Dave Abrahams
Sorry. As you know, to copy directory means override(replace) target in Linux and MacOSX, so you have to merge directory.
@Dave Abrahams
> But what is the markup syntax aside from
? Is it markdown syntax? Do I need to write in HTML aside from the
“tags?”
Yes…you have to write HTML tag. Unfortunately, Movable Type can’t apply multiple text filters.
I actually believe I got multiple filters working with the FormatStack plugin. The key is to put Markdown first in the stack, and then indent all the lines in between
by at least one space so Markdown treats the block as code. Apparently the “4 spaces or 1 tab” restriction that markdown used to recognize code blocks has been lifted.
Can you explain the difference between plain “SyntaxHighlighter” and “SyntaxHighlighter + Convert Line Breaks?”
Thanks!
@Dave Abrahams
Hi, Dave.
When “SyntaxHighlighter + Convert Line Breaks” is selected, SyntaxHighlighter for MT applies “Convert Line Breaks” text filter and “SyntaxHighlighter” text filter.
about “Convert Line Breaks”:
http://www.movabletype.org/documentation/author/text-formatting.html
I have written code to apply multiple text filters in the plugin
And I think that I can add “SyntaxHighlighter + Markdown” text filter (If I have much time..)
Ummm. it seems FormatStack plugin works fine.
http://labs.makotokw.com/mtdev/en/2009/05/test-formatstack.html
Yep, it’s working for me, too. I actually have to put SyntaxHighlighter first in the chain, or HTML cruft gets inserted into the code blocks. I don’t need indents in the code when I do it that way, either.
Now what I really need is fine-grained control over syntax highlighted code. For example, I’d like certain regions of the code to be presented as bold text. Any idea how?
@Dave Abrahams
I think that the plugin should have configuration on next version.
http://alexgorbatchev.com/wiki/SyntaxHighlighter:Configuration
Has the Perl support been given much testing? There’s an obvious bug in Plugin.pm (look at the perl entry in %spbrushlist in tag_sh_include_20 – it has an extra .sh on the end). But even after fixing that, I still can’t get any highlighting.
What’s the best place to get support for this plugin? Should I just post questions here or do you have a request tracker anywhere? Also, is there a source code repository anywhere?
@Dave Cross
Dave, it looks like here is Trac for this plugin.
As for Perl support, basic highlighting “works for me”(after I removed the extraneous suffix you mention). But I upgraded SyntaxHighlighter to 2.0.320. See http://tu.wesolek.net/2009/09/perl-test-in-mt.html for the result.
Though I’m not from the Movable Type world, people visiting your blog might be interested in other available brushes as well. The most recent version of the Highlighter contains some more brushes, but I compiled a list that contains all the brushes I could find on the internet, which means: many more languages can be supported! Check my list of downloadable syntaxes at UnderMyHat.org, or add this link to your post
– Abel –
i host 5 of my blogs on Blogspot and it is really good for beginners. but if you want something with more features, nothing beats wordpress”.”
I’ve just installed this plugin, but there is a problem with SyntaxHighLighter + Convert Line Breaks. You end up with HTML markup being displayed in the code segments. Is there a solution for this?
Thanks