Changeset 666410
- Timestamp:
- 02/11/2013 05:05:34 PM (13 years ago)
- Location:
- goodbye-syntax-highlighter/trunk
- Files:
-
- 2 edited
-
goodbye-syntax-highlighter.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
goodbye-syntax-highlighter/trunk/goodbye-syntax-highlighter.php
r647604 r666410 4 4 Plugin URI: https://github.com/visoft/goodbye-syntax-highlighter 5 5 Description: Say goodbye to syntaxhighlighter and hello to highlight.js 6 Version: 0.1. 16 Version: 0.1.2 7 7 Author: Damien White (Visoft, Inc.) 8 8 Author URI: http://www.visoftinc.com … … 11 11 12 12 /* 13 Copyright 2012 Visoft, Inc. <info@visoftinc.com>13 Copyright 2012-2013 Visoft, Inc. <info@visoftinc.com> 14 14 15 15 This file is part of goodbye-syntax-highlighter … … 20 20 (at your option) any later version. 21 21 22 Collapsing Archivesis distributed in the hope that it will be useful,22 Goodbye Syntax Highlighter is distributed in the hope that it will be useful, 23 23 but WITHOUT ANY WARRANTY; without even the implied warranty of 24 24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 26 26 27 27 You should have received a copy of the GNU General Public License 28 along with Collapsing Archives; if not, write to the Free Software28 along with Goodbye Syntax Highlighter; if not, write to the Free Software 29 29 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 30 30 */ … … 35 35 36 36 function gbsh_covert_code_blocks( $text ) { 37 return preg_replace( '|<pre class="[\"]*brush:\s?([^;]*);[^>]*>([^<]*)</pre>|se', 'gbsh_convert_code(\'$2\',\'$1\');', $text); 37 $text = preg_replace_callback('%<pre class="["]*brush:\s?([^;]*);[^>]*>([^<]*)</pre>%sim', 'gbsh_convert_code', $text); 38 39 $text = preg_replace_callback('%<pre lang="([^"]*)"[^>]*>([^<]*)</pre>%sim', 'gbsh_convert_code', $text); 40 41 return $text; 38 42 } 39 43 40 function gbsh_convert_code( $code, $language) { 41 $code = stripslashes( trim( str_replace(array('&', ''', '"'), array('&','\'','"'), $code) ) ); 44 function gbsh_convert_code( $matches ) { 45 // You can vary the replacement text for each match on-the-fly 46 // $matches[0] holds the regex match 47 // $matches[n] holds the match for capturing group n 48 $code = stripslashes( trim( str_replace(array('&', ''', '"'), array('&','\'','"'), $matches[2]) ) ); 49 $language = $matches[1]; 50 42 51 // covert csharp into cs 43 52 if ($language == 'csharp') $language = 'cs'; -
goodbye-syntax-highlighter/trunk/readme.txt
r647604 r666410 2 2 Contributors: dwhitevisoft 3 3 Donate link: http://www.visoftinc.com/ 4 Tags: highlight.js, syntax, code, pre, highlight, syntaxhighlighter 4 Tags: highlight.js, syntax, code, pre, highlight, syntaxhighlighter, geshi 5 5 Requires at least: 3.1 6 6 Tested up to: 3.5 7 Stable tag: 0.1. 17 Stable tag: 0.1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Say goodbye to plugins like SyntaxHighlighter Evolved and hello to highlight.js. With this plugin, you can seamlessly transition from one to another.11 Say goodbye to plugins like SyntaxHighlighter Evolved and WP-Syntax (NEW!) and hello to [highlight.js](http://softwaremaniacs.org/soft/highlight/en/). With this plugin, you can seamlessly transition from one to another. 12 12 13 13 == Description == … … 25 25 So there you have it. This WordPress plugin will go through and process your SyntaxHighlighter style blocks into ones that highlight.js works with out-of-the-box. It will also add the language that you have specified with the `brush` class and add it as a class on the `<code />` element ([following the HTML5 recommendation](http://www.w3.org/html/wg/drafts/html/master/text-level-semantics.html#the-code-element)). Nothing is changed in the DB, so if you decide to go back to SyntaxHighlighter, you can without any issues. 26 26 27 ## GeSHi 28 This plugin now supports conversion of [GeSHi](http://qbnz.com/highlighter/) style code blocks! Now you can move from plugins such as [WP-Syntax](http://wordpress.org/extend/plugins/wp-syntax/) and [WP-GeSHi-Highlight](http://wordpress.org/extend/plugins/wp-geshi-highlight) to highlight.js. 29 30 GeSHi uses the syntax that is *close* to SyntaxHighlighter, except instead of putting the language in the `class` attribute, it uses the `lang` attribute. Similar to the SyntaxHighligher conversion, it will go through and process your GeSHi style blocks into ones that highlight.js works with out-of-the-box. It will also add the language that you have specified with the `lang` attribute and add it as a `class` on the `<code />` element. 31 27 32 == Installation == 28 33 … … 36 41 = 0.1.0 = 37 42 * Initial release 43 38 44 = 0.1.1 = 39 45 * Modified output to use the HTML5 recommended syntax highlighting class names, e.g. `language-ruby`. For more information, see [the HTML5 spec](http://www.w3.org/html/wg/drafts/html/master/text-level-semantics.html#the-code-element) 46 47 = 0.1.2 = 48 * Added conversion of GeSHi style code blocks
Note: See TracChangeset
for help on using the changeset viewer.