Dec 29 2008

WP-SynHighlight

FractalizeR @ 1:13 pm

What is it?

WP-SynHighlight is a WordPress plugin that allows easy syntax highlighting of source code you post in your blog. It works much like any other BBCode tag. It highlights everything you put between codesyntax BB code tags

You can download plugin and read a comprehensive description of all additional features provided by it  at it’s official page at Plugins @ WordPress.org page. Below you will find a set of examples for various programming languages:

Java language example:

import java.util.*;
public class Sample {
    public static void main(String[] args) {
        // Создание объекта по шаблону.
        List<String> strings = new LinkedList<String>();
        strings.add("Hello");
        strings.add("world");
        strings.add("!");
        for (String s : strings) {
            System.out.print(s);
            System.out.print(" ");
        }
    }
}

PHP language example:

<?php
    function parse_code () {
        // Start the timer
        $start_time = microtime();
        // Firstly, if there is an error, we won't highlight
        if ($this->error) {
            //Escape the source for output
            $result = $this->hsc($this->source);
            //This fix is related to SF#1923020, but has to be applied regardless of
            //actually highlighting symbols.
            $result = str_replace(array('<SEMI>', '<PIPE>'), array(';', '|'), $result);
            // Timing is irrelevant
            $this->set_time($start_time, $start_time);
            $this->finalise($result);
            return $result;
        }

C++ Language example:

#include <iostream>   // для использования std::cout
#include <vector>     // для std::vector<>
#include <map>        // для std::map<> и std::pair<>
#include <algorithm>  // для std::for_each()
#include <string>     // для std::string
 
using namespace std;  // используем пространство имён "std"
 
void display_item_count(pair< string const, vector<string> > const& person) {
   // person - это пара двух объектов: person.first - это его имя,
   // person.second - это список его предметов (вектор строк)
   cout << person.first << " is carrying " << person.second.size() << " items" << endl;
}
 
int main()
{
   // объявляем карту со строковыми ключами и данными в виде векторов строк
   map< string, vector<string> > items;
 
   // Добавим в эту карту пару человек и дадим им несколько предметов
   items["Anya"].push_back("scarf");
   items["Dimitri"].push_back("tickets");
   items["Anya"].push_back("puppy");
 
   // Переберём все объекты в контейнере
   for_each(items.begin(), items.end(), display_item_count);

Some screenshots:

29 Responses to “WP-SynHighlight”

  1. Sonar says:

    Отличнейший плагин. С виду простой, а результат поражает. Еще бы прикрутить подсветку кода в комментариях.
    мой небольшой обзор http://dobrih.net/2009/01/podsvetka-programmnogo-koda-v-wordpress/

  2. Kevin Blake's Blog - Even the wrong words seem to rhyme » Blog Archive » Code Highlighting, and the magic of LINQ says:

    [...] I picked up the WP-SynHighlight extension for WordPress.  Which gives some rather cool code-highlighting through [...]

  3. Wordpress плагины, лучшие вордпресс плагины. Wordpress обратная связь, подсветка кода wordpress. says:

    [...] WP-SynHighlight – при частой работе с редактором тем, необходимо установить подсветку кода wordpress редактора, так как удобнее ориентироваться в коде. Подсветка кода wordpress в данном плагине реализована просто и хорошо смотриться, поэтому рекомендую. [...]

  4. FractalizeR’s WebSite » [JavaScript] PHP PCRE_DOT_ALL option emulation in JavaScript says:

    [...] my WP-SynHighlight WordPress plugin, I came to a need of parsing multilined shortcode like this: Code block   <many [...]

  5. FractalizeR’s WebSite » [JavaScript] EditArea: Realtime Syntax Highlighting JavaScript Library says:

    [...] improving my WordPress plugin WP-SynHighlight, I chose EditArea as a source code editor with realtime syntax highlighting. The syntax of language [...]

  6. WP-SynHighlight für WordPress says:

    [...] für WordPress 6. Januar 2010 | Autor: KHK Das Plugin WP-SynHighlight für WordPress von Vladislav Rastrusny realisiert Syntax Highlighting in Postings und [...]

  7. WP-SynHighlight ermöglicht Syntax Highlighting says:

    [...] unseren RSS Feed abonnieren.Powered by WP Greet Box WordPress Plugin Das WordPress Plugin WP-SynHighlight ermöglicht Syntax Highlighting in Postings und Kommentaren. Das Plugin verfügt über [...]

  8. Plugins fuer Syntax-Highlighting | Internet und Webpromotion says:

    [...] Fractalizer.ru mit WP-SynHighlighting, leider englischsprachig [...]

  9. WordPress插件推荐-1月19日 - WordPress 非官方中文站 says:

    [...] WP-SynHighlight 文章类插件:WP-SynHighhlight高亮插件 [...]

  10. PHP Code mit dem Plugin WP-SynHighlight anzeigen says:

    [...] gut, wenn man für die Päsentation ein Tool zur Verfügung hat. Das WordPress Plugin WP-SynHighlight von Vladislav Rastrusny realisiert Syntax Highlighting in Postings und Kommentaren des Blogs. Das [...]

  11. NsYta says:

    If I don’t want to display the code-block,,,What can I do. ???
    Because When the code has only one line…it display the code-block looks too heavery

  12. FractalizeR says:

    You can change theme to whatever you want. Look at plugin folder \theme directory. You can customize it as you wish.

  13. WordPress插件推荐-1月19日 | Kum的天空 says:

    [...] WP-SynHighlight 文章类插件:WP-SynHighhlight高亮插件 [...]

  14. The pain of posting code into wordpress | Some More Bytes says:

    [...] after reading a ton of documentation, and trying to find the proper way to do it I found this great plugin. WP-Synhighlight It is Geshi based, and it has a code editor included which will respect all the [...]

  15. افضل 10 اضافات لكتابة الكود داخل مدونتك says:

    [...] تمكنك هذه الاضافة من كتابة الكود داخل مدونتك بطريقة سهلة، ومن خلال هذه الاضافة لن تحتاج إلى التبديل بين المحرر المتطور ومحرر HTML  وهى اضافة رائعة،  تحتوى على العديد من المميزات لمشاهدة شكل الكود فى التدوينة اذهب الى صفحة الاضافة WP-SynHighlight. [...]

  16. wp-popular.com » Blog Archive » FractalizeR’s WebSite » WP-SynHighlight says:

    [...] the original post: FractalizeR’s WebSite » WP-SynHighlight Tags: [...]

  17. 大绵羊的博客 » Blog Archive » WordPress插件推荐-1月19日 says:

    [...] WP-SynHighlight 文章类插件:WP-SynHighhlight高亮插件 [...]

  18. 大绵羊的博客 » Blog Archive » WordPress插件推荐-1月19日 says:

    [...] WP-SynHighlight 文章类插件:WP-SynHighhlight高亮插件 [...]

  19. 9. SyntaxHighlighter Plus | MR G5 says:

    [...] تمكنك هذه الاضافة من كتابة الكود داخل مدونتك بطريقة سهلة، ومن خلال هذه الاضافة لن تحتاج إلى التبديل بين المحرر المتطور ومحرر HTML  وهى اضافة رائعة،  تحتوى على العديد من المميزات لمشاهدة شكل الكود فى التدوينة اذهب الى صفحة الاضافة WP-SynHighlight. [...]

Leave a Reply

You must be logged in to post a comment. Login now.