Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,332 members, 7,808,146 topics. Date: Thursday, 25 April 2024 at 07:45 AM

Java Syntax Highlighter For Smf 1.0.12 - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Java Syntax Highlighter For Smf 1.0.12 (2306 Views)

Programming Your Own Code Syntax Highlighter / Parse Error: Syntax Error, Unexpected T_else In C:\ / Strange Syntax Errors In PHP (2) (3) (4)

(1) (Reply) (Go Down)

Java Syntax Highlighter For Smf 1.0.12 by Nobody: 3:52am On Jul 28, 2011
Dear NL Programmers,

If you are a Java programmer and you regularly post Java code on this forum, I made a syntax highlighter that will convert your Java code into the equivalent SMF markup language. So, suppose your java file name is Knuth.java simply enter

   java -jar JavaSMFSyntaxHighlighter.pdf Knuth.java

on your command line and the program will produce a file called javaSMF.txt. The program file is attached. (It is actually a jar file, I really need to learn to use github). Now copy the contents of javaSMF.txt into NL message box and click Reply. Let me know if there are any bugs; if there are they will undoubtedly be incorrect syntax highlighting.



Example:
Now suppose there exists a file called Nonsense.java whose contents are shown below:

  /*
   * Testing the JavaSyntaxSMFHighlighter
   * This code makes absolutely no sense.
   * Only for testing and demonstration.
   */
     
   package Nonesense;
   import edu.caltech.omotodun.*;
   import africa.nigeria.*;

   public final class Tools
   {
      private int x = 656456;
      private float ddf = 323.00E23f;
      static {
         native void()
         {
            register();
         }
      }
      public static merge(int[] array1, int[] array2)
      {
         char c = '\u2334';
         String s = "\n\tNL is a fun place";
         switch(c)
         {
            case 'a':
               do
               {
                  System.out.print("Sani Abacha was a great leader"wink;
               } while(s != null & yes != false);
            break;

            return x == 0x34 ? 'x' : "2332";
         }
      }
      public static void main(String[] args)
      {
         if(this.nothing != 20)
         {
            synchronized(this)
            {
               notifyAll();
            }
         }
      }
   }


After entering

   java -jar JavaSMFSyntaxHighlighter.pdf Nonsense.java

The file javaSMF.txt was created in my CLI current directory. Then I copied the contents of the javaSMF.txt in the post below.

Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 3:52am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 4:19am On Jul 28, 2011
funny highlighter but cool, wud download it wen m home
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 4:24am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 4:30am On Jul 28, 2011
[size=15pt]Hmm wanted to do this a long time ago but not everyone uses Textmate. I coded a better syntax highlighter or ma sch's forum with ruby and shell and some regular expressions cheesy,  I wrote a lot ofregular expressions to parse java, xml, php and some others, Ddnt manage to parse c/c++ very well tho cause i ddnt have the chance to test it[/size]
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 4:35am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 4:41am On Jul 28, 2011
Oh and shouldn't it be java -jar JavaSMFSyntaxHighlighter.pdfjar Knuth.java
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 4:45am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 4:57am On Jul 28, 2011
really, so if i pass a pdf as argument that wud be fine, hmmm gotta check that
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 5:02am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 5:06am On Jul 28, 2011
cool,ddnt know.

test:
class Factorial
{
public static void main(String[] args)
{
int num = Integer.parseInt(args[0]);
System.out.println("Factorial of " + num +" is " + fact(num));
}

static int fact(int n)
{
if(n<=1){
return 1;
}
return n * fact(n-1);
}
}
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 5:12am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 5:31am On Jul 28, 2011
Hmmm lemme give it a try, Wah kinda code do you wanna test it with?
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 5:40am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 6:19am On Jul 28, 2011
LOl like ma Aquarium class cheesy?
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 6:42am On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by Mobinga: 3:56pm On Jul 28, 2011
Awesome! The output txt file is a joy to behold.

import java.net.*;

public class PortScanner {



public static void main(String args[])
{
int startPortRange=0;
int stopPortRange=0;

startPortRange = Integer.parseInt(args[0]);
stopPortRange = Integer.parseInt(args[1]);



for(int i=startPortRange; i <=stopPortRange; i++)
{
try
{
Socket ServerSok = new Socket("127.0.0.1",i);
System.out.println("Port " +i+ " in use");
ServerSok.close();
}
catch (Exception e)
{ System.out.println("Port "+i+ " not in use");}

}
}
}
Re: Java Syntax Highlighter For Smf 1.0.12 by Mobinga: 4:11pm On Jul 28, 2011
<?php
if (isset($_POST['domain'])){
$domain = trim($_POST['domain']);
$rstart = intval(trim($_POST['rstart']));
$rstop = intval(trim($_POST['rstop']));
for($i = $rstart; $i <= $rstop; $i++) {
        $check = @fsockopen($domain, $i, $errno, $errstr, 3);
        if($check) {
            echo "[-] Port '$i' is open<br/>";
        }
else {[/b]echo [b]"
[-] Port '$i' is not open :: $errno $errstr<br/>";}
    }
}

?>
Re: Java Syntax Highlighter For Smf 1.0.12 by Mobinga: 4:12pm On Jul 28, 2011
Nice.
Re: Java Syntax Highlighter For Smf 1.0.12 by Nobody: 5:05pm On Jul 28, 2011
Re: Java Syntax Highlighter For Smf 1.0.12 by adamricky: 7:52am On Jul 29, 2011
Syntax Highlighter 1.0
- SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript. To get an idea of what SyntaxHighlighter is capable of, have a look at the demo.

The project was started in 2004 and since then has gained a lot of acceptance. Version 2.0 is the new page in history of the project representing a near complete rewrite, clean up, optimization, standard compliance and new features.

- Current SyntaxHighlighter version: 1.5.2

SFM 1.1.7, 1.1.8, 1.1.9, 1.1.10 Supported Themes
- Default

Supported Languajes by SyntaxHighlighter
- C++, C#, CSS, Delphi, Java, Java Script, PHP, Python, Ruby, Sql, VB, XML/HTML

How to use it?
- Using the code bbc tag as is describe below:

//the code is here

Where the “alias” can be replaced by the languajes alias:
cpp, c, c++, c#, c-sharp, csharp, css, delphi, pascal, java, js, jscript, javascript, php, py, python, rb, ruby, rails, ror, sql, vb, vb.net, xml, html, xhtml, xslt

- Examples:
1 System.out.println("this is java!"wink;
1 echo "this is a String in Php";

Credits
- The SyntaxHighlighter was coded by alexgorbatchev.com
- SyntaxHighlighter and SMF integration was coded by Delibertad.com
Re: Java Syntax Highlighter For Smf 1.0.12 by Mobinga: 2:06pm On Oct 30, 2011
This thread should be stickied
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 5:44pm On Oct 30, 2011
Any reason why?
Re: Java Syntax Highlighter For Smf 1.0.12 by Mobinga: 10:24am On Oct 31, 2011
@Fayimora!! Long time. grin

Anyhow So it get's more notice, nairaland is not friendly to codes at all. This needs to receive more recognition so @omotodun can improve on this!
Re: Java Syntax Highlighter For Smf 1.0.12 by Fayimora(m): 11:16am On Oct 31, 2011
Yeah LNG time, been way too busy recently, Ok thread has been sticked cheesy

(1) (Reply)

Am In Lag, I Need A Job. / If You Want To Learn Angularjs With Php..using XAMP ...why Not Join In Here / As A Programmer, How Are You Coping In This Economy?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 44
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.