Syntax Highligting for Code

Started by G_G, June 08, 2011, 01:08:17 pm

Previous topic - Next topic

Ryex

February 18, 2013, 03:07:31 pm #20 Last Edit: February 18, 2013, 03:43:53 pm by Ryex
Welp, it looks good on the dark theme now. Enjoy folks. Blizzard probably did just as much work as I have on this.


for your information it attempts to auto detect the language but it can get confused if the section is small you can help it pick the language with the code tag property

[code=ruby][/code] Ruby
[code=php][/code] PHP
[code=cpp][/code] C++
[code=cs][/code]   C#

ect.

EDIT:
At least it would if the code tag still put that value after the :  is the code tag header...
FIX IT BLIZZ :(

Spoiler: ShowHide
Code: php

$codes[] = array(
'tag' => 'code',
'type' => 'unparsed_content',
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $txt;
// select all and copy code to clipboard mod
static $codecounter = 0;
$codecounter++;
$tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ":" . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a>
</div>' . $codeWrapHTML . ';
'),
'block_level' => true,
);
$codes[] = array(
'tag' => 'code',
'type' => 'unparsed_equals_content',
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $txt;
// select all and copy code to clipboard mod
static $codecounter = 0;
$codecounter++;
$tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ":" . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a>
</div>' . $codeWrapHTML . ';
'),
);
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

February 18, 2013, 04:03:57 pm #21 Last Edit: February 18, 2013, 04:11:30 pm by Blizzard
I'll have to look into that another time. Judging by the code, I'm not even sure that feature is actually supported.

EDIT: I'll add that code right away. Let's see if it works.

EDIT: And you broke my selection code, Ryex. :P

EDIT: Alright, I added your code (with some modifications), but I don't think it's working.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

February 18, 2013, 04:17:58 pm #22 Last Edit: February 18, 2013, 04:19:57 pm by Ryex
it doesn't always pick the right syntax sadly but most of the time it does and when it doens't half the time the addition of the right code type will help it pick. actually you might want to put an extra space after the :
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

February 18, 2013, 04:59:35 pm #23 Last Edit: February 18, 2013, 05:16:40 pm by Blizzard
Sure, if it helps.

EDIT:

Code: ruby
int main()
{
   printf("Hellooooooooooooooooooooo.\n");
   return 0;
}


Code: cpp
int main()
{
   printf("Hellooooooooooooooooooooo.\n");
   return 0;
}


EDIT: I think all it really does is detect keywords, comments and stuff enclosed in quotes, etc.

EDIT: I updated Subs-Highlight.php in my DB in case you wanna use it. But be careful. I removed some stuff that I don't need.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

February 18, 2013, 05:51:48 pm #24 Last Edit: February 18, 2013, 06:26:02 pm by Ryex
I figured it out. if you explicitly set the class of the code tag it uses that highlighting
also only the

'type' => 'unparsed_equals_content',
should set the code header I realized

Code: php

// Code tag
function ch_code_tag(&$codes)
{
   global $modSettings, $txt, $settings;

   $darkThemeIDS = array(3, 5, 7, 9, 11, 13);

   if (in_array($settings['theme_id'], $darkThemeIDS))
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code>
// Code tag
function ch_code_tag(&$codes)
{
   global $modSettings, $txt, $settings;

   $darkThemeIDS = array(3, 5, 7, 9, 11, 13);

   if (in_array($settings['theme_id'], $darkThemeIDS))
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code>$1</code></pre></div></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div></div>"';
   }
   else
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><pre><code>$1</code></pre></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div>"';
   }

   if (!empty($modSettings['ch_enable']))
   {
       foreach ($codes as $tag => $dump)
           if ($dump['tag'] == 'code') unset($codes[$tag]);
           
       $codes[] =  array(
           'tag' => 'code',
           'type' => 'unparsed_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML1 . ';
           '),
           'block_level' => true,
       );
       $codes[] = array(
           'tag' => 'code',
           'type' => 'unparsed_equals_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": " . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML2 . ';
           '),
           'block_level' => true,
       );          
   }
   
   // Copyright Info
   if (isset($context['current_action']) && $context['current_action'] == 'credits')
       $context['copyrights']['mods'][] = '<a href="http://dragomano.ru/page/code-highlighting" target="_blank">Code Highlighting</a> &copy; 2010&ndash;2012, Bugo';
}
</code></pre></div></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code class=\"" . $data[1] . "\">
// Code tag
function ch_code_tag(&$codes)
{
   global $modSettings, $txt, $settings;

   $darkThemeIDS = array(3, 5, 7, 9, 11, 13);

   if (in_array($settings['theme_id'], $darkThemeIDS))
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code>$1</code></pre></div></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div></div>"';
   }
   else
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><pre><code>$1</code></pre></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div>"';
   }

   if (!empty($modSettings['ch_enable']))
   {
       foreach ($codes as $tag => $dump)
           if ($dump['tag'] == 'code') unset($codes[$tag]);
           
       $codes[] =  array(
           'tag' => 'code',
           'type' => 'unparsed_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML1 . ';
           '),
           'block_level' => true,
       );
       $codes[] = array(
           'tag' => 'code',
           'type' => 'unparsed_equals_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": " . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML2 . ';
           '),
           'block_level' => true,
       );          
   }
   
   // Copyright Info
   if (isset($context['current_action']) && $context['current_action'] == 'credits')
       $context['copyrights']['mods'][] = '<a href="http://dragomano.ru/page/code-highlighting" target="_blank">Code Highlighting</a> &copy; 2010&ndash;2012, Bugo';
}
</code></pre></div></div>"';
   }
   else
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><pre><code>
// Code tag
function ch_code_tag(&$codes)
{
   global $modSettings, $txt, $settings;

   $darkThemeIDS = array(3, 5, 7, 9, 11, 13);

   if (in_array($settings['theme_id'], $darkThemeIDS))
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code>$1</code></pre></div></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div></div>"';
   }
   else
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><pre><code>$1</code></pre></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div>"';
   }

   if (!empty($modSettings['ch_enable']))
   {
       foreach ($codes as $tag => $dump)
           if ($dump['tag'] == 'code') unset($codes[$tag]);
           
       $codes[] =  array(
           'tag' => 'code',
           'type' => 'unparsed_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML1 . ';
           '),
           'block_level' => true,
       );
       $codes[] = array(
           'tag' => 'code',
           'type' => 'unparsed_equals_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": " . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML2 . ';
           '),
           'block_level' => true,
       );          
   }
   
   // Copyright Info
   if (isset($context['current_action']) && $context['current_action'] == 'credits')
       $context['copyrights']['mods'][] = '<a href="http://dragomano.ru/page/code-highlighting" target="_blank">Code Highlighting</a> &copy; 2010&ndash;2012, Bugo';
}
</code></pre></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><pre><code class=\"" . $data[1] . "\">
// Code tag
function ch_code_tag(&$codes)
{
   global $modSettings, $txt, $settings;

   $darkThemeIDS = array(3, 5, 7, 9, 11, 13);

   if (in_array($settings['theme_id'], $darkThemeIDS))
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code>$1</code></pre></div></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><div class=\"dark_theme_code\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div></div>"';
   }
   else
   {
       $codeWrapHTML1 = '<div class=\"block_code\" id=\"code_a" . $codecounter . "\"><pre><code>$1</code></pre></div>"';
       $codeWrapHTML2 = '<div class=\"block_code\" id=\"code_b" . $codecounter . "\"><pre><code class=\"" . $data[1] . "\">$1</code></pre></div>"';
   }

   if (!empty($modSettings['ch_enable']))
   {
       foreach ($codes as $tag => $dump)
           if ($dump['tag'] == 'code') unset($codes[$tag]);
           
       $codes[] =  array(
           'tag' => 'code',
           'type' => 'unparsed_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML1 . ';
           '),
           'block_level' => true,
       );
       $codes[] = array(
           'tag' => 'code',
           'type' => 'unparsed_equals_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": " . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML2 . ';
           '),
           'block_level' => true,
       );          
   }
   
   // Copyright Info
   if (isset($context['current_action']) && $context['current_action'] == 'credits')
       $context['copyrights']['mods'][] = '<a href="http://dragomano.ru/page/code-highlighting" target="_blank">Code Highlighting</a> &copy; 2010&ndash;2012, Bugo';
}
</code></pre></div>"';
   }

   if (!empty($modSettings['ch_enable']))
   {
       foreach ($codes as $tag => $dump)
           if ($dump['tag'] == 'code') unset($codes[$tag]);
           
       $codes[] =  array(
           'tag' => 'code',
           'type' => 'unparsed_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_a" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML1 . ';
           '),
           'block_level' => true,
       );
       $codes[] = array(
           'tag' => 'code',
           'type' => 'unparsed_equals_content',
           'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
               global $txt;
               // select all and copy code to clipboard mod
               static $codecounter = 0;
               $codecounter++;
               $tag[\'content\'] = "<div class=\"codeheader\">" . $txt[\'smf238\'] . ": " . $data[1] . " <a href=\"javascript:void(0)\" title=\"" . $txt[\'codeselectall\'] . "\" onclick=\"javascript:selectall(\'code_b" . $codecounter . "\');return false;\">" . $txt[\'codeselectall\'] . "</a></div>' . $codeWrapHTML2 . ';
           '),
           'block_level' => true,
       );          
   }
   
   // Copyright Info
   if (isset($context['current_action']) && $context['current_action'] == 'credits')
       $context['copyrights']['mods'][] = '<a href="http://dragomano.ru/page/code-highlighting" target="_blank">Code Highlighting</a> &copy; 2010&ndash;2012, Bugo';
}



tags you can use for code highlighting:

  • python
  • profile (like output form python's profiler)
  • ruby
  • perl
  • php
  • scala
  • go
  • xml (also supports HTML with inline css and javascript)
  • markdown
  • django (Django templates)
  • css
  • json
  • javascript
  • coffeescript
  • actionscript
  • vbscript
  • http (like output from curl the standard way HTTP headers as displayed in text)
  • lua
  • applescript
  • delphi
  • java
  • cpp (c++)
  • objectivec
  • vala
  • cs (c#)
  • d
  • rsl (RenderMan RSL)
  • rib (RenderMan RIB)
  • mel (Maya Embedded Language)
  • glsl
  • sql
  • smalltalk
  • lisp
  • clojure
  • ini
  • apache (like .htaccess)
  • nginx
  • diff (SVN or GIT diffs ect.)
  • dos (DOS batch files)
  • bash (.sh scripts)
  • cmake
  • axapta
  • 1c
  • avrasm (AVR Assembler)
  • vhdl
  • parser3
  • tex (TeX)
  • brainfuck (BrainFuck)
  • haskell
  • erlang
  • erlang-repl
  • rust
  • matlab
  • r
  • no-highlight (disables highlighting)


    You might want to update the actual highlight script too as I've noticed there has been a few updates since this this mode went out.
    https://dl.dropbox.com/u/20709011/highlight.pack.js
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

February 19, 2013, 12:57:59 pm #25 Last Edit: February 19, 2013, 01:00:38 pm by Blizzard
class A; end;

Code: test
class A; end;

Code: Ruby
class A; end;

Code: ruby
class A; end;


EDIT: It seems to be working except for one bug. When I used code tags without the =something part, then a weird L appears there (first example). You think you can fix that, Ryex?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

February 19, 2013, 02:05:58 pm #26 Last Edit: February 19, 2013, 02:08:24 pm by Ryex
I already did in the code I posted. as I said the array with the type "unparsed_content" SHOULD NOT append the $data[1] part after the "Code:" text. only the "unparsed_equals_content" should

also, did you update the Highlight script like I suggested at the end of my last post?

I appears that as long as you use one of the tags I posted it will use that but if it doesn't recognize the tag it will auto detect anyway.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Ah, I see now *fixes* and yes, I did.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

well folks. there you go, one fancy Syntax Highlighting system fresh off the presses.

you may bow and bequeath us with favors as time permits.
shouts of adoration are appreciated but we, for the most part, can not return your feelings.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

I like how when I go into the script help section and I see a code tag it's all highlighted and stuff, makes my want to do a fist pump because my brain is like "OMG YES THIS IS SO EASY TO READ!"
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

March 13, 2013, 09:09:15 am #31 Last Edit: March 19, 2013, 02:32:39 pm by Blizzard
I just noticed that it seems to often fail to recognize the language, especially in short code segments. I think I'll set it to Ruby by default and then using code=something would allow different highlighting for other languages.

EDIT: Wow, this was frustratingly difficult. Not because it was a difficult thing to do, but because the javascript code looks like it's been horribly unreadable on purpose. :/ The variable names are usually just one letter and the entire thing is in one single line with no spaces. Anyway, this is how it's done.

There should be a code segment like this somewhere in the beginning:

Code: javascript
if(e[p[o]]||p[o]=="no-highlight"){return p[o]}


When this is added at the end, it causes the certain language to become default if none was specified:

Code: javascript
if(p[o]==""){return "ruby"}


EDIT: Hey, Ryex, there seems to be an error in the Ruby parser. Check out this script:

http://forum.chaos-project.com/index.php/topic,2312.msg174554.html#msg174554

Notice how the parameters labeled x0, y0, etc. have their numbers highlighted as if they were literals. This is wrong. :/ You think you can fix that?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

ya no. the highlight.js parser isn't easy to follow the code is a bit wonky. you can try seeing if there is a new update for it though. (checks himself.) nope last update was 13.10.2012
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

See if this can at least be reported.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

June 23, 2014, 01:04:55 am #34 Last Edit: June 23, 2014, 01:12:44 am by Ryex
There has been an update to Highlight.js http://highlightjs.org/
Release 8.0 https://github.com/isagalaev/highlight.js/releases/tag/8.0

  • auto detection has been improved
  • a bunch of styles have been improved (including ruby's)
  • new languages added
  • language aliases have been added (ie `js` for javascript and `html` which previously had to xml)

    and a bunch more.

    update the .js file if you would please Blizz.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

June 23, 2014, 01:47:08 am #35 Last Edit: June 23, 2014, 11:56:44 am by Blizzard
I remember that I modded some things in the script. I don't think it will be just copy-paste, but I'll check it out.

EDIT: Nope, I simply can't get it to work. Replacing doesn't help and there are no instructions as to where to put the extra folders or if they need to be loaded separately. I tried using the prebuilt version, it didn't work either.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

June 23, 2014, 11:55:21 pm #36 Last Edit: June 24, 2014, 11:07:35 pm by Ryex
use this https://dl.dropboxusercontent.com/u/20709011/Random%20Stuff/highlight.zip

you link the highlight.pack.js, link one of the styles from the style directory and you should be good to go.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

June 24, 2014, 02:19:57 am #37 Last Edit: June 26, 2014, 04:26:55 pm by Blizzard
That might work. The old file I have is also called highlight.pack.js. I'll try it out when I get home from work.

EDIT: Nope, I'm still having trouble to get things running. It removes the select-code button and just turns everything into black text. I can give you CP's source if you feel like messing around with it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

alright. time to mess around with this. toss it here Blizz. point me to the files in question (i've kinda forgotten :P)
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Alright, I'll send it to you when I get home.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.