CARVIEW |
Every repository with this icon (

Every repository with this icon (

Description: | Use Google Code's script to prettify code and pre tags edit |
Homepage: | edit |
Public Clone URL: |
git://github.com/sixapart/mt-plugin-GCPrettify.git
Give this clone URL to anyone.
git clone git://github.com/sixapart/mt-plugin-GCPrettify.git
|
Your Clone URL: |
Use this clone URL yourself.
git clone git@github.com:sixapart/mt-plugin-GCPrettify.git
|
tree 520c40eec0116e3cfd029654ab4a6cfb382f46db
parent e8b6de25a06a65fb1781942249aef621a9fc9756
name | age | message | |
---|---|---|---|
![]() |
LICENSE.md | Thu Nov 12 16:46:17 -0800 2009 | adding license [beausmith] |
![]() |
README.md | Thu Nov 12 16:48:38 -0800 2009 | updating readme [beausmith] |
![]() |
mt-static/ | Thu Nov 12 15:10:04 -0800 2009 | initial commit. moving from Six Apart internal ... [beausmith] |
![]() |
plugins/ | Thu Nov 12 15:10:04 -0800 2009 | initial commit. moving from Six Apart internal ... [beausmith] |
GCPrettify, a plugin for Movable Type
Authors: Six Apart, Ltd.
Copyright: 2009 Six Apart, Ltd.
License: Artistic License 2.0
Overview
GCPrettify is a plugin designed to allow easy use of Google Code's prettify.js
script for syntax highlighting of code samples.
GCPrettify 0.5 uses the May 21, 2009 release of the prettify.js code.
Requirements
- MT4.x
Features
Provides the global MT tag modifier
gcprettify
which when set will replace all<code>
html tags in the output content of the modified MT tag with<code class="prettyprint">
.Any
<code>
html tags with an existing class such as<code class="my-example">
or<code class="nopretty">
will not be replaced.Alters the default "Convert Line Breaks" filter by restricting the creation of
<br />
and<p>
tags within the context of<pre>
blocks.
Documentation
Integrate Prettify Functionality
Add the Prettify script and style links to the html
<head>
element:<link href="<$mt:StaticWebPath$>plugins/GCPrettify/prettify.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<$mt:StaticWebPath$>plugins/GCPrettify/prettify.js"></script>
To trigger the styling the
prettyPrint()
javascript function must be called after the html page has loaded. To do this use one of the following methods after including the above scripts:After the
<script>
tag loading themt.js
script (which may be in the<head>
as well) add the following:<script type="text/javascript">mtAttachEvent('load', prettyPrint);</script>
If using jQuery, add this code after including the jQuery script:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { prettyPrint(); }); </script>
Update template tags outputting content which will contain
<code>
html tags.If
<code>
html tags will be added in the "body" or "extended" of entries, search the Movable Type templates for these tags:<$mt:EntryBody$> <$mt:EntryExtended$>
Update these tags with the
gcprettify
attribute and a true value:
Save the templates.<$mt:EntryBody gcprettify="1"$> <$mt:EntryExtended gcprettify="1"$>
Create a new entry and paste the following code into the body of the entry:
<pre><code> /* calculate nth fibonacci number */ int fib(int n) { if (n < 2) return 1; return fib(n - 2) + fib(n - 1); } </code></pre>
Publish and view entry.
The "prettyPrint" JavaScript function called on load will then detect all
<code>
tags with the "prettyprint" class, parse their contents, and the appropriate span elements for syntax highlighting.Further details on the operations of this script are available at the google-code-prettify page.
View the page html source and you'll see that MT has updated the
<code>
html tag with the "prettyprint" class:<pre><code class="prettyprint"> /* calculate nth fibonacci number */ int fib(int n) { if (n < 2) return 1; return fib(n - 2) + fib(n - 1); } </code></pre>
Styling <code>
HTML Tags in Other Templates
Because the prettify.js
script will "prettify" any <code>
tag which has the "prettyprint" class, any <code>
blocks which have the "prettyprint" class in the published html source code will be "prettified" upon page load.
In index templates manually add the "prettyprint" class to all <code>
html elements:
<pre><code class="prettyprint">
document.write('<b>Hello World</b>');
</code></pre>
Installation
- Move the GCPrettify plugin directory to the MT
plugins
directory. - Move the GCPrettify
mt-static
directory to themt-static/plugins
directory.
Should look like this when installed:
$MT_HOME/
plugins/
GCPrettify/
mt-static/
plugins/
GCPrettify/
More in-depth plugin installation instructions.
Desired Features
- Blog-level overrides of the default GCPrettify style sheet
- Alteration of "Convert Line Breaks" filtering only within tags affected by the gcprettify tag modifier
Support
This plugin is not an official Six Apart release, and as such support from Six Apart for this plugin is not available.