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:

62 Responses to “WP-SynHighlight”

  1. Kaluriel says:

    My apologies, it wasn’t the new WordPress, I had updated some new plugins at the same time I had upgraded my WordPress, one of them broke it.
    Thanks for the help. :)

  2. Apache solve | Linux tutorials says:

    [...] WP-SynHighlight WP Plugin [...]

  3. 10 Best Syntax Highlighter Wordpress Plugins | TutorialChip says:

    [...] be changed to your liking in the WPadmin section of your blog.FV Code Highlighter5. WP-SynHighlightWP-SynHighlight is a WordPress plugin that allows easy syntax highlighting of source code you post in your blog. It [...]

  4. افزونه قرار دادن کدهای برنامه نویسی در پست ها - پرتال آموزشی آکسایا | پرتال آموزشی آکسایا says:

    [...] فریم ها و … زیادی را تولید کنید .مشاهده نمونه کار : WP-SynHighlight۵افزونه SyHiمشاهده نمونه : SyHi۶افزونه WP-CodeBoxنمونه : [...]

  5. alwaro says:

    hi, first, i have to say what a good work!!! this plugin is very cool and much better than others… now i´d like to tell you a problem with it, in my blog i use diferent kind of scripts to show in post and my first problem with this plugin is the colors… for example, with applescript source code there are characters showed in white color (there are other colors but they aren´t any problem with them) and it´s difficult see them well with the background by default. How can i change the background color with an easy way… I´d like to put it in black but i´ll hace the same problem with black characters so i think the best solution will be grey (grease) colour like your samples background color but more dark (the needed to see well the white chars and the black ones)

    This is my problem with the colors… http://cl.ly/2G312E3x2R2K2M1q102U

    Sorry for my poorly english, i´m spanish :) and thanks!!

  6. FractalizeR says:

    Well, you have to modify CSS to match colors on your website.

  7. ৬টি গুরুত্বপূর্ণ Syntax Highlighter - বাংলাদেশী ওয়েব ডিজাইনার এন্ড ডেভেলপার ব্লগ : বাংলাদেশী ওয়েব ডিজাইনার says:

    [...] হয়েছে: 2১. SyntaxHighlighter EvolvedDownload২. File Inliner PluginDownload৩. WP-SynHighlightDownload৪. FV Code HighlighterDownload৫. Google Syntax HighlighterDownload৬. [...]

  8. Best WordPress Plugins to Display and Highlight Code within your Blog - Freelancer Gang says:

    [...] 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. WP-SynHighlight [...]

Leave a Reply

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