Syntax Highlight di blogger

berikut adalah contoh bagaimana cara menambahkan syntax codingan kalian di dalam postingan


let count = 0;

const intervalId = setInterval(() => {
  count++;
  console.log(count); // This will log the number every second
}, 1000); // Executes every 1000 milliseconds (1 second)

Contoh Syntax Java :

package mybasicjava.ardie;

import javax.swing.JOptionPane;

public class Mobil {

    String warna = "merah";
    String merk = "BMW";

    void maju() {
        System.out.println("Mobil = "+ merk + ", Warna = "+ warna + " bergerak maju");
    }
    
    void mundur() {
        System.out.println("Mobil = "+ merk + ", Warna = "+ warna + " bergerak mundur");
    }
    
    public static void main(String []args) {
    	
    	// membuat object mobil saya 
        Mobil callMethod = new Mobil();
        callMethod.maju();
        callMethod.mundur();
        
        String inputNama = JOptionPane.showInputDialog("Masukkan nama =");
        String inputNilai = JOptionPane.showInputDialog("Masukkan nilai = ");
        
        System.out.println("Nama = "+ inputNama);
        System.out.println("Nilai = "+ inputNilai);
    }

}

asdasdsa asdasdas contoh syntax JSON :

[
    {
        "url": "https://wolnelektury.pl/katalog/autor/adam-asnyk/",
        "href": "https://wolnelektury.pl/api/authors/adam-asnyk/",
        "name": "Adam Asnyk",
        "slug": "adam-asnyk"
    },
    {
        "url": "https://wolnelektury.pl/katalog/autor/adam-kaczanowski/",
        "href": "https://wolnelektury.pl/api/authors/adam-kaczanowski/",
        "name": "Adam Kaczanowski",
        "slug": "adam-kaczanowski"
    },
    {
        "url": "https://wolnelektury.pl/katalog/autor/adam-mickiewicz/",
        "href": "https://wolnelektury.pl/api/authors/adam-mickiewicz/",
        "name": "Adam Mickiewicz",
        "slug": "adam-mickiewicz"
    }
]

contoh syntax NodeJS :

const http = require('http')
const cofee = require('./coffe');
const moment = require('moment');

const { firstName, lastName } = require('./user');


const currDate= moment().format('MMM Do YYYY');
//const Tiger = require('./Tiger');
// const tiger = new Tiger();

const hostname = process.env.NODE_ENV !== 'production' ? 'localhost': 'localhost';
const port = 3000;

const requestHandler = (req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Hello, World !!\n');
};

const server = http.createServer(requestHandler);

const memoryInfo = process.memoryUsage();

console.log("Current Date = "+ currDate);
console.log("Memory usage = "+ JSON.stringify(memoryInfo));
console.log("var coffe => "+ JSON.stringify(cofee));

console.log("firstName=> "+ firstName);
console.log("lasttName=> "+ lastName);

server.listen(port, hostname, ()=> {
    console.log(`Server berjalan pada http://${hostname}:${port}`);
})

contoh syntax Bash Programming

@echo off 

setlocal enabledelayedexpansion 
set topic[0]=comments 
set topic[1]=variables 
set topic[2]=Arrays 
set topic[3]=Decision making 
set topic[4]=Time and date 
set topic[5]=Operators 

for /l %%n in (0,1,5) do ( 
   echo !topic[%%n]! 
)

PAUSE

support dengan syntax berikut : Mulai dari Apache, Bash, CoffeeScript, C++, C#, CSS, Diff, Go, HTTP, TOML (INI), Java, JavaScript, JSON (JSON with Comments), Kotlin, Less, Lua, Makefile, Markdown, Nginx, Objective-C, Perl, PHP, plaintext, Properties, Python, Ruby, Rust, SCSS, Shell Session, SQL, Swift, TypeScript, HTML, XML, dan YAML. 

Untuk mengganti Tema syntax bisa liat di link berikut : 
https://cdnjs.com/libraries/highlight.js 

Referensi : https://www.bungfrangki.com/2019/12/cara-memasang-syntax-highlighter.html


Semoga Bermanfaat, Salam Coding
Syntax Highlight di blogger Syntax Highlight di blogger Reviewed by BES Oracle Apps Knowledge on Desember 17, 2024 Rating: 5

Tidak ada komentar

Blogger templates