Read this before posting code GeSHi Syntax Highlighter

  • Thread starter Greg Bernhardt
  • Start date
  • Tags
    Code
In summary, Physics Forums has recently implemented GeSHi syntax highlighting for almost 200 programming languages. This feature can be accessed by clicking the "+" button on the editor and selecting the appropriate language for your code. Additionally, the conversation includes a sample code for finding the area of a triangle using Heron's formula, with input and output instructions. The conversation also includes sample code in Java and Python for writing random integers to a file and finding the median of a list of numbers, respectively. The conversation concludes with a sample code for creating a plasma effect using VGA graphics.
  • #1
19,437
10,006
Physics Forums now supports GeSHi syntax highlighting for nearly 200 programming languages. Simply hit the + button on the editor. Select the code option, use general code, type in your code. Then in the first bbcode tag put in the language you want to use. For example:

[code=fortran]
Fortran:
C AREA OF A TRIANGLE - HERON'S FORMULA
C INPUT - CARD READER UNIT 5, INTEGER INPUT, NO BLANK CARD FOR END OF DATA
C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPAYS ERROR MESSAGE ON OUTPUT
  501 FORMAT(3I5)
  601 FORMAT(" A= ",I5,"  B= ",I5,"  C= ",I5,"  AREA= ",F10.2,"SQUARE UNITS")
  602 FORMAT("NORMAL END")
  603 FORMAT("INPUT ERROR OR ZERO VALUE ERROR")
      INTEGER A,B,C
   10 READ(5,501,END=50,ERR=90) A,B,C
      IF(A=0 .OR. B=0 .OR. C=0) GO TO 90
      S = (A + B + C) / 2.0
      AREA = SQRT( S * (S - A) * (S - B) * (S - C))
      WRITE(6,601) A,B,C,AREA
      GO TO 10
   50 WRITE(6,602)
      STOP
   90 WRITE(6,603)
      STOP
      END

[code=c]
C:
#include<stdio.h>
main()
{
   int n;
   printf("Enter an integer\n");
   scanf("%d",&n);
   if ( n%2 == 0 )
      printf("Even\n");
   else
      printf("Odd\n");
   return 0;
}

[code=java]
Java:
//sample code to write 100 random ints to a file, 1 per line

import java.io.PrintStream;
import java.io.IOException;
import java.io.File;

import java.util.Random;

public class WriteToFile
{    public static void main(String[] args)
    {    try
        {    PrintStream writer = new PrintStream( new File("randInts.txt"));
            Random r = new Random();
            final int LIMIT = 100;

            for(int i = 0; i < LIMIT; i++)
            {    writer.println( r.nextInt() );
            }
            writer.close();
        }
        catch(IOException e)
        {    System.out.println("An error occurred while trying to write to the file");
        }
    }
}

[code=python]
Python:
import unittest
def median(pool):
    copy = sorted(pool)
    size = len(copy)
    if size % 2 == 1:
        return copy[(size - 1) / 2]
    else:
        return (copy[size/2 - 1] + copy[size/2]) / 2
class TestMedian(unittest.TestCase):
    def testMedian(self):
        self.failUnlessEqual(median([2, 9, 9, 7, 9, 2, 4, 5, 8]), 7)
if __name__ == '__main__':
    unittest.main()

Enjoy :)
 
Last edited:
  • Like
  • Informative
Likes JD_PM, elusiveshame, Klystron and 8 others
Technology news on Phys.org
  • #3
Code:
{$A+,B-,D+,E-,F-,G+,I-,L+,N-,O-,R-,S-,V-,X-}
{$M 16384,0,655360}

uses vga,mycrt;

const
  byx = 256;
  byy = 256;

var
  mapptr : ^largearray;
  ranges :  array[0..320]of byte;
  dir    :  integer;
  x,y    :  byte;

procedure Palette;
external;
{$L palette.obj }

procedure PutPixel(x,y : word;color : byte);
begin
  mapptr^[(byy-y)*byx+x]:=color
end;

function GetPixel(x,y : word) : word;
begin
  GetPixel:=mapptr^[(byy-y)*byx+x];
end;

function newcolor(meancolor,n,divider : integer): integer;
var
  local : integer;
begin
  local:=(meancolor+n-random(2*n)) div divider;
  newcolor:=local;
  if local>250 then newcolor:=250;
  if local<5 then newcolor:=5
end;

procedure plasma(x1,y1,x2,y2 : word);
var
  xnew,ynew   : word;
  dxy         : word;
  p1,p2,p3,p4 : word;
begin
  if (x2-x1<2) and (y2-y1<2) then EXIT;
  p1:=GetPixel(x1,y1);
  p2:=GetPixel(x1,y2);
  p3:=GetPixel(x2,y1);
  p4:=GetPixel(x2,y2);
  xnew:=(x2+x1) shr 1;
  ynew:=(y2+y1) shr 1;
  dxy:=4*(x2-x1+y2-y1) div 3;
  if GetPixel(xnew,y1)=0 then PutPixel(xnew,y1,newcolor(p1+p3,dxy,2));
  if GetPixel(x1,ynew)=0 then PutPixel(x1,ynew,newcolor(p1+p2,dxy,2));
  if GetPixel(x2,ynew)=0 then PutPixel(x2,ynew,newcolor(p3+p4,dxy,2));
  if GetPixel(xnew,y2)=0 then PutPixel(xnew,y2,newcolor(p2+p4,dxy,2));
  PutPixel(xnew,ynew,newcolor(p1+p2+p3+p4,dxy,4));
  plasma(x1,y1,xnew,ynew);
  plasma(xnew,y1,x2,ynew);
  plasma(x1,ynew,xnew,y2);
  plasma(xnew,ynew,x2,y2);
end;

procedure make_map;
begin
  new(mapptr);
  fillchar(mapptr^,65535,0);
  PutPixel(0,0,128);
  PutPixel(0,199,128);
  PutPixel(319,0,128);
  PutPixel(319,199,128);
  plasma(0,0,256,256);
end;

procedure drawview(xpos,ypos,dir : integer);
const
  obsy = 30;
  sincos = 256;
var
  mapz,zobs : integer;
  ix,iy,iy1,iyprim,ixprim : integer;
  x,y,s : integer;
  i,j   : word;
  cosfi,sinfi : integer;
  mapcolor : integer;
begin
  fillchar(ranges,sizeof(ranges),200);
  zobs:=100+mapptr^[byx*(byy-ypos)+xpos];
  cosfi:=round(sincos*cos(dir/180*pi));
  sinfi:=round(sincos*sin(dir/180*pi));
  for iy:=ypos to ypos+55 do
  begin
    iy1:=1+2*(iy-ypos);
    s:=4+10*obsy div iy1;
    for ix:=xpos-50+ypos+50-iy to xpos+50-ypos-50+iy do
    begin
      ixprim:=xpos+((ix-xpos)*cosfi+(iy-ypos)*sinfi) div sincos;
      iyprim:=ypos+((iy-ypos)*cosfi-(ix-xpos)*sinfi) div sincos;
      x:=160+12*(ix-xpos)*obsy div iy1;
      if (x>=0) and (x+s<=318) then
      begin
        mapz:=mapptr^[byx*(byy-iyprim)+ixprim];
        mapcolor:=mapz;
        if mapz<46 then mapz:=45;
        y:=100+(zobs-mapz)*obsy div iy1;
        if (y<=199) and (y>=0) then
          for j:=1 to s do
          begin
            for i:=y to ranges[x+j] do
              screen[320*i+x+j]:=mapcolor;
            if y<ranges[x+j] then ranges[x+j]:=y
          end;
      end;
    end;
  end;
end;

begin
  randomize;
  make_map;
  graph256on;
  setcolors(@palette,1,255);
  x:=0; y:=0; dir:=0;
  repeat
    fillchar(screen,64000,0);
    drawview(x,y,dir);
    case readkey of
      _null :  case readkey of
                 _Lft  : dec(dir,10);
                 _Rght : inc(dir,10);
                 _Up   : begin
                           y:=y+round(4*cos(dir/180*pi));
                           x:=x+round(4*sin(dir/180*pi));
                         end;
                 _Down : begin
                           y:=y-round(4*cos(dir/180*pi));
                           x:=x-round(4*sin(dir/180*pi));
                         end;
               end;
      _esc  :  begin
                 graphstop;
                 HALT
               end
    end;
    dir:=dir mod 360
  until false;
end.
 
  • #4
Added Fortran, C/C++, Java and Python to the code language drop down. Not sure why it took me so long to do it :cool:
 
  • #5
I don't know I can write here or not. Sorry if not.
A small suggestion.
Make a window for entering the code is greater than or resizable.
It will be easier to edit the code.
 
  • #6
This is excellent!
But we always want more. ;>)
One thing that I need over and over again is to know the line numbers of the code. So many people post error messages that indicate line numbers and I always have to copy their code into my own editor to find the indicated line. It would also make it easier to reference specific lines in the discussion. Is there some way to automate line numbers in this syntax highlighter? If this is something you can force by default, that would be nice.
 
  • #7
I think Greg has to enable it and then its true for all listings on site. I couldn't find any simple markup to turn on unless we can provide additional options to the code tag like [ code=python line=1 ]

One problem though is that we won't be able to simply mark and copy code to try it out when helping a poster with a problem. Instead we'd have to reply to the post and copy it from the reply dialog editor box.
 
  • Like
Likes FactChecker
  • #9
jedishrfu said:
I think Greg has to enable it and then its true for all listings on site. I couldn't find any simple markup to turn on unless we can provide additional options to the code tag like [ code=python line=1 ]

One problem though is that we won't be able to simply mark and copy code to try it out when helping a poster with a problem. Instead we'd have to reply to the post and copy it from the reply dialog editor box.
In that case, I agree it is better to not have line numbers. I saw in their documentation, that they have a switch that places line numbers that will not be copied when you copy/paste. But you know how that is -- it so often doesn't work as advertised. I don't have any experience with it.
 
  • Like
Likes jedishrfu
  • #10
That could work! Geshi has been around for some time and is pretty reliable.

They may even have some means to have a clipboard icon that loads the clipboard with the source code.
 
  • Like
Likes FactChecker
  • #11
Is there a way to use this kind of software/editor option with standard text editors? I definitely like to code with color formatting, but usually just use NotePad for coding in Tcl/Tk. My C editor already has color coding built-in.
 
  • #12
The Atom editor can do syntax coloring as can vim and other editors for a multitude of languages.

https://atom.io/

I've been using it for a while and its quite cool. It bills itself as a hackable editor with hacks written in javascript.
 
  • Like
Likes berkeman
  • #13
I would say most modern code editors do the syntax highlighting.
 
  • #14
The prevalent code editor getting traction in Youtube videos on programming is the Sublime editor (free version and fancier paid version).

The Atom editor is free written in javascript and has many of the same Sublime features notably syntax coloring and the cool full sidebar program listing, There's also a lot of plugins available supporting code development in many languages.

Now back to Geshi...
 
  • #15
Greg Bernhardt said:
Added Fortran, C/C++, Java and Python to the code language drop down. Not sure why it took me so long to do it :cool:
Why aren't all the supported languages in the code language drop down? Especially since you cannot type in the value yourself and the GeSHi name is not necessarily evident. From the GeSHi website you can get all the codes:
HTML:
<select name="language">
                <option value="4cs">GADV 4CS</option>
                <option value="6502acme">MOS 6502 (6510) ACME Cross Assembler format</option>
                <option value="6502kickass">MOS 6502 (6510) Kick Assembler format</option>
                <option value="6502tasm">MOS 6502 (6510) TASM/64TASS 1.46 Assembler format</option>
                <option value="68000devpac">Motorola 68000 - HiSoft Devpac ST 2 Assembler format</option>
                <option value="abap">ABAP</option>
                <option value="actionscript">ActionScript</option>
                <option value="actionscript3">ActionScript 3</option>
                <option value="ada">Ada</option>
                <option value="aimms">AIMMS3</option>
                <option value="algol68">ALGOL 68</option>
                <option value="apache">Apache configuration</option>
                <option value="applescript">AppleScript</option>
                <option value="apt_sources">Apt sources</option>
                <option value="arm">ARM ASSEMBLER</option>
                <option value="asm">ASM</option>
                <option value="asp">ASP</option>
                <option value="asymptote">asymptote</option>
                <option value="autoconf">Autoconf</option>
                <option value="autohotkey">Autohotkey</option>
                <option value="autoit">AutoIt</option>
                <option value="avisynth">AviSynth</option>
                <option value="awk">awk</option>
                <option value="bascomavr">BASCOM AVR</option>
                <option value="bash">Bash</option>
                <option value="basic4gl">Basic4GL</option>
                <option value="bf">Brainfuck</option>
                <option value="bibtex">BibTeX</option>
                <option value="blitzbasic">BlitzBasic</option>
                <option value="bnf">bnf</option>
                <option value="boo">Boo</option>
                <option value="c">C</option>
                <option value="c_loadrunner">C (LoadRunner)</option>
                <option value="c_mac">C (Mac)</option>
                <option value="c_winapi">C (WinAPI)</option>
                <option value="caddcl">CAD DCL</option>
                <option value="cadlisp">CAD Lisp</option>
                <option value="cfdg">CFDG</option>
                <option value="cfm">ColdFusion</option>
                <option value="chaiscript">ChaiScript</option>
                <option value="chapel">Chapel</option>
                <option value="cil">CIL</option>
                <option value="clojure">Clojure</option>
                <option value="cmake">CMake</option>
                <option value="cobol">COBOL</option>
                <option value="coffeescript">CoffeeScript</option>
                <option value="cpp">C++</option>
                <option value="cpp-qt" class="sublang">&nbsp;&nbsp;C++ (Qt)</option>
                <option value="cpp-winapi" class="sublang">&nbsp;&nbsp;C++ (WinAPI)</option>
                <option value="csharp">C#</option>
                <option value="css">CSS</option>
                <option value="cuesheet">Cuesheet</option>
                <option value="d">D</option>
                <option value="dart">Dart</option>
                <option value="dcl">DCL</option>
                <option value="dcpu16">DCPU-16 Assembly</option>
                <option value="dcs">DCS</option>
                <option value="delphi">Delphi</option>
                <option value="diff">Diff</option>
                <option value="div">DIV</option>
                <option value="dos">DOS</option>
                <option value="dot">dot</option>
                <option value="e">E</option>
                <option value="ecmascript">ECMAScript</option>
                <option value="eiffel">Eiffel</option>
                <option value="email">eMail (mbox)</option>
                <option value="epc">EPC</option>
                <option value="erlang">Erlang</option>
                <option value="euphoria">Euphoria</option>
                <option value="ezt">EZT</option>
                <option value="f1">Formula One</option>
                <option value="falcon">Falcon</option>
                <option value="fo">FO (abas-ERP)</option>
                <option value="fortran">Fortran</option>
                <option value="freebasic">FreeBasic</option>
                <option value="freeswitch">FreeSWITCH</option>
                <option value="fsharp">F#</option>
                <option value="gambas">GAMBAS</option>
                <option value="gdb">GDB</option>
                <option value="genero">genero</option>
                <option value="genie">Genie</option>
                <option value="gettext">GNU Gettext</option>
                <option value="glsl">glSlang</option>
                <option value="gml">GML</option>
                <option value="gnuplot">Gnuplot</option>
                <option value="go">Go</option>
                <option value="groovy">Groovy</option>
                <option value="gwbasic">GwBasic</option>
                <option value="haskell">Haskell</option>
                <option value="haxe">Haxe</option>
                <option value="hicest">HicEst</option>
                <option value="hq9plus">HQ9+</option>
                <option value="html4strict">HTML</option>
                <option value="html5">HTML5</option>
                <option value="icon">Icon</option>
                <option value="idl">Uno Idl</option>
                <option value="ini">INI</option>
                <option value="inno">Inno</option>
                <option value="intercal">INTERCAL</option>
                <option value="io">Io</option>
                <option value="ispfpanel">ISPF Panel</option>
                <option value="j">J</option>
                <option value="java">Java</option>
                <option value="java5">Java(TM) 2 Platform Standard Edition 5.0</option>
                <option value="javascript">Javascript</option>
                <option value="jcl">JCL</option>
                <option value="jquery">jQuery</option>
                <option value="kixtart">KiXtart</option>
                <option value="klonec">KLone C</option>
                <option value="klonecpp">KLone C++</option>
                <option value="latex">LaTeX</option>
                <option value="lb">Liberty BASIC</option>
                <option value="ldif">LDIF</option>
                <option value="lisp">Lisp</option>
                <option value="llvm">LLVM Intermediate Representation</option>
                <option value="locobasic">Locomotive Basic</option>
                <option value="logtalk">Logtalk</option>
                <option value="lolcode">LOLcode</option>
                <option value="lotusformulas">Lotus Notes @Formulas</option>
                <option value="lotusscript">LotusScript</option>
                <option value="lscript">LScript</option>
                <option value="lsl2">LSL2</option>
                <option value="lua">Lua</option>
                <option value="m68k">Motorola 68000 Assembler</option>
                <option value="magiksf">MagikSF</option>
                <option value="make">GNU make</option>
                <option value="mapbasic">MapBasic</option>
                <option value="matlab">Matlab M</option>
                <option value="mirc">mIRC Scripting</option>
                <option value="mmix">MMIX</option>
                <option value="modula2">Modula-2</option>
                <option value="modula3">Modula-3</option>
                <option value="mpasm">Microchip Assembler</option>
                <option value="mxml">MXML</option>
                <option value="mysql">MySQL</option>
                <option value="nagios">Nagios</option>
                <option value="netrexx">NetRexx</option>
                <option value="newlisp">newlisp</option>
                <option value="nginx">nginx</option>
                <option value="nsis">NSIS</option>
                <option value="oberon2">Oberon-2</option>
                <option value="objc">Objective-C</option>
                <option value="objeck">Objeck Programming Language</option>
                <option value="ocaml">OCaml</option>
                <option value="ocaml-brief" class="sublang">&nbsp;&nbsp;OCaml (brief)</option>
                <option value="octave">GNU/Octave</option>
                <option value="oobas">OpenOffice.org Basic</option>
                <option value="oorexx">ooRexx</option>
                <option value="oracle11">Oracle 11 SQL</option>
                <option value="oracle8">Oracle 8 SQL</option>
                <option value="oxygene">Oxygene</option>
                <option value="oz">OZ</option>
                <option value="parasail">ParaSail</option>
                <option value="parigp">PARI/GP</option>
                <option value="pascal">Pascal</option>
                <option value="pcre">PCRE</option>
                <option value="per">per</option>
                <option value="perl">Perl</option>
                <option value="perl6">Perl 6</option>
                <option value="pf">OpenBSD Packet Filter</option>
                <option value="php">PHP</option>
                <option value="php-brief" class="sublang">&nbsp;&nbsp;PHP (brief)</option>
                <option value="pic16">PIC16</option>
                <option value="pike">Pike</option>
                <option value="pixelbender">Pixel Bender 1.0</option>
                <option value="pli">PL/I</option>
                <option value="plsql">PL/SQL</option>
                <option value="postgresql">PostgreSQL</option>
                <option value="postscript">PostScript</option>
                <option value="povray">POVRAY</option>
                <option value="powerbuilder">PowerBuilder</option>
                <option value="powershell">PowerShell</option>
                <option value="proftpd">ProFTPd configuration</option>
                <option value="progress">Progress</option>
                <option value="prolog">Prolog</option>
                <option value="properties">PROPERTIES</option>
                <option value="providex">ProvideX</option>
                <option value="purebasic">PureBasic</option>
                <option value="pycon">Python (console mode)</option>
                <option value="pys60">Python for S60</option>
                <option value="python">Python</option>
                <option value="q">q/kdb+</option>
                <option value="qbasic">QBasic/QuickBASIC</option>
                <option value="racket">Racket</option>
                <option value="rails">Rails</option>
                <option value="rbs">RBScript</option>
                <option value="rebol">REBOL</option>
                <option value="reg">Microsoft Registry</option>
                <option value="rexx">rexx</option>
                <option value="robots">robots.txt</option>
                <option value="rpmspec">RPM Specification File</option>
                <option value="rsplus">R / S+</option>
                <option value="ruby">Ruby</option>
                <option value="rust">Rust</option>
                <option value="sas">SAS</option>
                <option value="scala">Scala</option>
                <option value="scheme">Scheme</option>
                <option value="scilab">SciLab</option>
                <option value="scl">SCL</option>
                <option value="sdlbasic">sdlBasic</option>
                <option value="smalltalk">Smalltalk</option>
                <option value="smarty">Smarty</option>
                <option value="spark">SPARK</option>
                <option value="sparql">SPARQL</option>
                <option value="sql">SQL</option>
                <option value="standardml">StandardML</option>
                <option value="stonescript">StoneScript</option>
                <option value="systemverilog">SystemVerilog</option>
                <option value="tcl">TCL</option>
                <option value="teraterm">Tera Term Macro</option>
                <option value="text">Text</option>
                <option value="thinbasic">thinBasic</option>
                <option value="tsql">T-SQL</option>
                <option value="typoscript">TypoScript</option>
                <option value="unicon">Unicon (Unified Extended Dialect of Icon)</option>
                <option value="upc">UPC</option>
                <option value="urbi">Urbi</option>
                <option value="uscript">Unreal Script</option>
                <option value="vala">Vala</option>
                <option value="vb">Visual Basic</option>
                <option value="vbnet">vb.net</option>
                <option value="vbscript">VBScript</option>
                <option value="vedit">Vedit macro language</option>
                <option value="verilog">Verilog</option>
                <option value="vhdl">VHDL</option>
                <option value="vim">Vim Script</option>
                <option value="visualfoxpro">Visual Fox Pro</option>
                <option value="visualprolog">Visual Prolog</option>
                <option value="whitespace">Whitespace</option>
                <option value="whois">Whois (RPSL format)</option>
                <option value="winbatch">Winbatch</option>
                <option value="xbasic">XBasic</option>
                <option value="xml">XML</option>
                <option value="xorg_conf">Xorg configuration</option>
                <option value="xpp">X++</option>
                <option value="yaml">YAML</option>
                <option value="z80">ZiLOG Z80 Assembler</option>
                <option value="zxbasic">ZXBasic</option>
            </select>
 
  • Like
Likes DrClaude and BvU
  • #16
Support jack: I concede the full list is rather long, but at least a few more, like 'text', and 'LaTeX' should be in there, plus the possibility to type your own GeSHi value.

And: I see the editor has great difficulty with tabs. It's a difficult issue, but I think this way a lot of Fortran (yes, I know, old Fortran) gets rendered wrongly.
 
  • #17
jack action said:
Why aren't all the supported languages in the code language drop down?
The vast majority haven't ever seen action here. I added the few that I see the most here. Give me your list of the top ten you see posted here and I'll add them.
 
Last edited:
  • #18
Greg Bernhardt said:
The vast majority haven't never seen action here. I added the few that I see the most here. Give me your list of the top ten you see posted here and I'll add them.
For me, the revelation happened here with Matlab. I was wondering how the OP got 'Mathlab M' written in the header of his code. Then I realized that the code was correctly highlighted, even though I couldn't find it in the list. The easiest way I could make it happen was by selecting any code and then change it to 'matlab', not even 'matlab m'. So I knew some software was recognizing the code, not just a happy coincidence. With a little research, I found this thread and the actual list. Have I known, I could of probably used 'vbscript' here also.

I'm not going to list which languages should be there or not, I'm just saying that the process to use one not on the list is not intuitive at all and very well hidden. Since we cannot put our own input in the 'code' dialog box and there are no instructions, the logical conclusion for a typical user (at least me) is that if it's not on the list, it is not recognized.

I don't know if it is possible, but this seems to be a good candidate for an autocomplete dropdown (i.e. <datalist> element) rather than a <select> element.
 
  • Like
Likes Greg Bernhardt
  • #19
I agree JA but I didn't write the addon and the author isn't receptive to suggestions :)
 
  • #20
Languages I reference are mostly: Java / Groovy, JavaScript, Fortran, C / C++, Python / Jython, Matlab, Julia, Lisp / Clojure, Scala, SQL, Awk and shell scripting not necessarily in that order.

Others much less often would be Prolog, Lua, Forth, Assembler, Ruby, Rex's, COBOL and Basic.
 
  • Like
Likes Klystron
  • #21
Greg Bernhardt said:
I agree JA but I didn't write the addon and the author isn't receptive to suggestions :)
Well, you've got at least three of us backing you up for a next attempt. 'Not receptive', yuch!
 
  • #22
Greg Bernhardt said:
Added Fortran, C/C++, Java and Python to the code language drop down. Not sure why it took me so long to do it :cool:

It was age.
 
  • #23
So I still think adding a couple hundred languages to a drop down is a bad idea. If we can come up with the top say 15 used on PF. I will add them.
 

1. What is GeSHi Syntax Highlighter?

GeSHi Syntax Highlighter is a popular open-source library that is used to add syntax highlighting to code snippets in various programming languages. It is commonly used in websites and blogs to make code easier to read and understand.

2. How do I use GeSHi Syntax Highlighter?

To use GeSHi Syntax Highlighter, you first need to download and install the library on your website or blog. Once installed, you can wrap your code snippets in appropriate GeSHi tags for the programming language you are using. When the page is rendered, the code will be highlighted according to the syntax rules of that language.

3. What programming languages does GeSHi support?

GeSHi supports over 200 programming languages, including popular ones like Java, Python, C++, and HTML. A full list of supported languages can be found on the GeSHi website.

4. Can I customize the syntax highlighting in GeSHi?

Yes, GeSHi offers a wide range of customization options, such as changing the colors of the highlighted code, changing the font size, and adding line numbers. These options can be adjusted through the GeSHi configuration file.

5. Is GeSHi Syntax Highlighter free to use?

Yes, GeSHi is completely free to use and is released under the GNU General Public License. You can use it for personal or commercial projects without any restrictions.

Similar threads

  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
2
Views
758
  • Programming and Computer Science
Replies
2
Views
265
  • Programming and Computer Science
Replies
1
Views
934
  • Programming and Computer Science
Replies
4
Views
892
  • Programming and Computer Science
Replies
4
Views
572
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
Back
Top