Menampilkan Script di WordPress

Bagi para pengguna WordPress, Den Adit punya tips nih ..!! Kalo biasanya kita nampilin source code
pake tag <pre> </pre>,  nah buat nampilin lebih keren plus ada highlight syntax-nya,  wordpress menyediakan shortcode buat nampilin script.

Nih contohnya :

import java.util.Scanner;

public class test {

    public static void main(String[] args) {

        //Menampilkan insialisasi nilai awal
        Scanner input = new Scanner( System.in );

        //Pertanyaan untuk menerima inputan
        System.out.print ("Masukkan nama Anda: ");
        String nama = input.nextLine();
        System.out.print ("Masukkkan bilangan bulat: ");
        int bilangan1 = input.nextInt();
        System.out.print ("Masukkkan bilangan pecahan: ");
        double bilangan2 = input.nextDouble();

        //Tampilkan isi inputan dalam variabel
        System.out.printf( "nNama Anda adalah %s.",nama );
        System.out.printf( "nBilangan pertama adalah %d.",bilangan1 );
        System.out.printf( "nBilangan kedua adalah %.2f.",bilangan2 );

    }

}

 


Caranya tinggal masukin script ke tag sourcecode
[sourcecode language="javascript" light="true" wraplines="false"]
.....
[/sourcecode]

Terus buat settingan tampilan bisa di set dengan parameter ni nih :

  • autolinks (true/false) — Makes all URLs in your posted code clickable. Defaults to true.
  • collapse (true/false) — If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Good for large code posts. Defaults to false.
  • firstline (number) — Use this to change what number the line numbering starts at. It defaults to 1.
  • gutter (true/false) — If false, the line numbering on the left side will be hidden. Defaults to true.
  • highlight (comma-seperated list of numbers) — You can list the line numbers you want to be highlighted. For example “4,7,19″.
  • htmlscript (true/false) — If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as PHP inside of HTML. Defaults to false and will only work with certain code languages.
  • light (true/false) — If true, the gutter (line numbering) and toolbar (see below) will be hidden. This is helpful when posting only one or two lines of code. Defaults to false.
  • padlinenumbers (true/false/integer) — Allows you to control the line number padding. true will result in automatic padding, false will result in no padding, and entering a number will force a specific amount of padding.
  • toolbar (true/false) — If false, the toolbar containing the helpful buttons that appears when you hover over the code will not be shown. Defaults to true.
  • wraplines (true/false) — If true, line line wrapping will be disabled. This will cause a horizontal scrollbar to appear for long lines of code.

Kalo belum puas bisa ente baca sendiri disini nih http://en.support.wordpress.com/code/posting-source-code/…!!!  Selamat mencoba …. | Hazz |

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml&#8221; xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>WordPress.com Code Example</title>
</head>
<body>
<h1>WordPress.com Code Example</h1><p><?php echo ‘Hello World!’; ?></p><p>This line is highlighted.</p><p>This line is very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long.</p>

This    is    an
example    of    smart
tabs.

<p><a href=”http://wordpress.com/”>WordPress.com</a></p&gt;
</body>
</html>

Advertisements

One thought on “Menampilkan Script di WordPress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s