Apa itu Syntax Highlighting dan apa fungsinya ?, Syntax Highlighting atau Syntax Highlighter adalah fitur pada teks editor yang menampilkan atau menyoroti teks baik sebagian atau seluruh terutama source code dalam berbagai warna, font, model dan sebagainya sesuai dengan kategori istilah yang digunakan/ diinginkan.
Fungsinya selain mempercantik tampilan, dengan menggunakan Syntax Highlighting penulis atau pembaca dapat dengan mudah mengenal contoh source code atau bahasa terstruktur seperti bahasa pemrograman (programming language) atau bahasa markup (markup language).
Implementasi dari Syntax Highlighting ini bisa pada halaman website, blog atau forum online. Seringnya digunakan sebagai kode Prensentasi pada contoh source code seperti Javascript, HTML, XML, CSS, Python, PHP, JSON, CoffeeScript, Java, SQL, Apache, Haskell, Erlang, Ruby, C++, Objective C dan lainnya.
Sebagai referensi ada cukup banyak pilihan syntax highlighter yang dapat digunakan dengan berbagai kekurangan dan kelebihan yang dimilikinya, berikut diantaranya Syntax Highlighter, Highlight.JS, GeSHi (Generic Syntax Highlighter), Google Code Prettify, DlHighlight, Beauty Of Code, JUSH (Javascript Syntax Highlighter), Pygments (Python Syntax Highlighter), SHJS (Syntax Highlighting in JavaScript), Chili, CodePress dan sebagainya.
Live view tampilan Syntax Highlighting Prism JS Dengan Material Tabs
/* ===== Contoh Code HTML =====*/
<div class="tabs">
<div class="tabs-header">
<div class="border"></div>
<ul>
<li class="activetab"><a href="#tab-1" tab-id="1" ripple="ripple" ripple-color="#4285F4">Tabs 1</a></li>
<li><a href="#tab-2" tab-id="2" ripple="ripple" ripple-color="#4285F4">Tabs 2</a></li>
<li><a href="#tab-3" tab-id="3" ripple="ripple" ripple-color="#4285F4">Tabs 3</a></li>
<li><a href="#tab-4" tab-id="4" ripple="ripple" ripple-color="#4285F4">Tabs 4</a></li>
<li><a href="#tab-5" tab-id="5" ripple="ripple" ripple-color="#4285F4">Tabs 5</a></li>
</ul>
<nav class="tabs-nav">
<i class="fa fa-chevron-left" id="previcon" ripple="ripple" ripple-color="#FFF" style="padding-right: 5px;"></i>
<i class="fa fa-chevron-right" id="nexticon" ripple="ripple" ripple-color="#FFF" style="padding-left: 5px;"></i>
</nav>
</div>
<div class="tabs-content">
<div class="tab activetab" tab-id="1">
<div style="text-align:justify;">
1. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</div><br/><br/>
</div>
<div class="tab" tab-id="2">
<div style="text-align:justify;">
2. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.</div><br/><br/>
</div>
<div class="tab" tab-id="3">
<div style="text-align:justify;">
3. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div><br/><br/>
</div>
<div class="tab" tab-id="4">
<div style="text-align:justify;">
4. <b>Where can I get some?</b><br/>
<br/>
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</div><br/><br/>
</div>
<div class="tab" tab-id="5">
<div style="text-align:justify;">
5. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.<br/>
<br/>
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</div><br/><br/>
</div>
</div>
</div>
/* ===== Contoh Code CSS =====*/
.tabs {
z-index: 15px;
position: relative;
background: #FFFFFF;
width: 95%;
border-radius: 4px;
box-sizing: border-box;
margin: 10px 0px 10px 10px;
overflow: hidden;
border:1px solid #f2f2f2;
box-shadow: 0px .5vh 5px 0px rgba(0,0,0,.25);
border-right: solid 2px rgba(255, 255, 255, 0.4);
border-top: solid 2px rgba(255, 255, 255, 0.4);
}
.tabs-header {
position: relative;
background: #333333;
overflow: hidden;
border-bottom:2px solid #f2f2f2;
}
.tabs-header .border {
position: absolute;
bottom: 0;
left: 0;
background: #4285F4;
width: auto;
height: 5px;
transition: 0.3s ease;
margin-left:0px;
}
.tabs-header ul {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: calc(100% - 68px);
padding-left:0px;
margin-bottom:10px;
margin-top: 10px;
list-style:none;
}
.tabs-header li {
transition: 0.3s ease;
list-style:none;
}
.tabs-header a {
z-index: 1;
display: block;
box-sizing: border-box;
padding: 10px 10px 10px 20px;
color: #FFFFFF;
font-weight: 500;
text-decoration: none;
text-transform: uppercase;
}
.tabs-nav {
position: absolute;
top: 0;
right: 0;
background: #4285F4;
display: flex;
align-items: center;
height: 100%;
padding: 10px 10px 0px 10px;
color: #FFFFFF;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.tabs-nav:before {
content: '';
z-index: 1;
position: absolute;
top: 0;
left: 0;
height: 100%;
}
/* --------------------------------- */
/* ===== Contoh Code JS =====*/
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'/>
Catatan
Code pada tampilan tersebut adalah sebatas contoh code untuk tampilan CSS, JS dan HTML. Silahkan sahabat ganti dan sesuaikan dengan code yang ingin sahabat tampilkan nanti.
Code pada tampilan tersebut adalah sebatas contoh code untuk tampilan CSS, JS dan HTML. Silahkan sahabat ganti dan sesuaikan dengan code yang ingin sahabat tampilkan nanti.
Gimana keren bukan ? Lantas bagaimana cara membuat dan memasangnya di blog ?, berikut tutorial
Cara Membuat Syntax Highlighting Prism JS Dengan Material Tabs
- Budayakan membaca dan mencoba sebelum sahabat berkomentar.
- Tutorial yang saya bagikan sudah 100% berfungsi di template Blogger bawaan ataupun template modifikasi pada umumnya (tergantung pada template yang sahabat gunakan).
- Selamat mencoba dan tetap semangat...
Demikian semoga membantu...Silahkan sahabat memodifikasi lanjut untuk penempatan, ukuran, warna, dan model gambar disesuaikan dengan gaya template sahabat. Hindari memodifikasi yang berlebihan terkadang malah jadi menggangu baik tampilan maupun fungsi.

0 komentar:
Post a Comment