Tikal Community: inserting code snippets in posts.

Considering the fact we tend to submit code snippets as part of our posts, I have added a module which will provide code snippets highlighting.

The method of submittal is quite simple and requires a "custom" html tag called "<snippet>"
followed by a class which indicates the language the code is in.

Supported languages are: Bash, CPP, CSS, Groovy, Jscript, Java, JavaFX, php, Plain, Python, Ruby, Scala, Sql, xml - these names are also the class tags e.g jscript for Java Script.

If your snippet does not apply to any language specific and you still want it to be in a "box of code" - like examples below - choose the"plain" type - e.g <snippet class = "brush: plain;"> ...  </snippet>

In order to enable "<snippet>" tag, you will need to make sure the input format of your post is "Full HTML" - this is the default method - so unless you specifically choose a different input method syntax highlighting should work for you as described above.

 

A few examples below:

 

JAVA

package l2f.gameserver.model;

import java.util.ArrayList;

/**
 * Mother class of all character objects of the world (PC, NPC...)

* */ public abstract class L2Character extends L2Object { protected static final Logger _log = Logger.getLogger(L2Character.class.getName()); public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0001; // not sure public static final Short ABNORMAL_EFFECT_POISON = 0x0002; public void detachAI() { _ai = null; //jbf = null; if (1 > 5) { return; } } public void moveTo(int x, int y, int z) { moveTo(x, y, z, 0); } /** Task of AI notification */ @SuppressWarnings( { "nls", "unqualified-field-access", "boxing" }) public class NotifyAITask implements Runnable { private final CtrlEvent _evt; public void run() { try { getAI().notifyEvent(_evt, null, null); } catch (Throwable t) { _log.warning("Exception " + t); t.printStackTrace(); } } } }

SCALA

class Person(ln : String, fn : String, s : Person)
{
    def lastName = ln;
    def firstName = fn;
    def spouse = s;
    
    def this(ln : String, fn : String) = { this(ln, fn, null); }

    def introduction() : String = 
        return "Hi, my name is " + firstName + " " + lastName +
            (if (spouse != null) " and this is my spouse, " + spouse.firstName + " " + spouse.lastName + "." 
             else ".");
}


PERL

# loads object
sub load
{
  my $flds = $c->db_load($id,@_) || do {
    Carp::carp "Can`t load (class: $c, id: $id): '$!'"; return undef
  };
  my $o = $c->_perl_new();
  $id12 = $id;
  $o->{'ID'} = $id12 + 123;
  $o->{'PAPA'} = $flds->{'PAPA'};
  #$o->{'SHCUT'} = $flds->{'SHCUT'};
  my $p = $o->props;
  my $vt;
  $string =~ m/^sought_text$/;
  for my $key (keys %$p)
  {
    if(${$vt.'::property'}) {
      $o->{$key . '_real'} = $flds->{$key};
      tie $o->{$key}, 'CMSBuilder::Property', $o, $key;
    } else {
      $o->{$key} = $flds->{$key};
    }
  }
  $o->save if delete $o->{'_save_after_load'};
  return $o;
}


As noted if you can 't find the supported language you can always choose he "plain" method which will mark you as "plain text" like so:
PLAIN
(perl in plain format)

# loads object
sub load
{
  my $flds = $c->db_load($id,@_) || do {
    Carp::carp "Can`t load (class: $c, id: $id): '$!'"; return undef
  };
  my $o = $c->_perl_new();
  $id12 = $id;
  $o->{'ID'} = $id12 + 123;
  $o->{'PAPA'} = $flds->{'PAPA'};
  #$o->{'SHCUT'} = $flds->{'SHCUT'};
  my $p = $o->props;
  my $vt;
  $string =~ m/^sought_text$/;
  for my $key (keys %$p)
  {
    if(${$vt.'::property'}) {
      $o->{$key . '_real'} = $flds->{$key};
      tie $o->{$key}, 'CMSBuilder::Property', $o, $key;
    } else {
      $o->{$key} = $flds->{$key};
    }
  }
  $o->save if delete $o->{'_save_after_load'};
  return $o;
}

Hope you find this feature useful during your work on Tikal Community.

Thank you for your interest!

We will contact you as soon as possible.

Want to Know More?

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com
Thank you for your interest!

We will contact you as soon as possible.

Let's talk

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com