Komentar

Syintax Code Highlighter

Andi Suardi Nasa
Gaya Syintax Code Highlighter

Syntax Highlighter

Adalah sebuah fitur penyorotan sintaksis yang digunakan dalam bahasa pemrograman, skrip, dalam bahasa markah seperti HTML, CSS, dan JavaScript

Elemen Tag html Code

/*]]>*/</style> adalah tanda penutup untuk tag style di HTML. Tag style digunakan untuk mengatur gaya tampilan suatu dokumen HTML. Tanda penutup ini digunakan untuk mengakhiri bagian gaya yang ditentukan oleh tag style

Kelas Pre Css

/* Styles for code block with syntax highlighting */

/* Shared styles for .pre and .cmC i[rel=pre] elements */
.pre {
  background: var(--synxBg);
  color: var(--synxC);
  direction: ltr;
}

.pre:not(.tb) {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  margin: 1.7em auto;
  font-family: var(--fontC);
}

.pre pre {
  margin: 0;
  color: inherit;
  background: inherit;
}

/* Styles for ::before pseudo-element */
.pre::before,
.cmC i[rel=pre]::before {
  content: '<>';
  display: flex;
  justify-content: flex-end;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  background: inherit;
  color: var(--synxGray);
  font-size: 10px;
  padding: 0 10px;
  z-index: 2;
  line-height: 30px;
  font-weight: bold;
  font-size: 14px;
}

.pre:not(.tb).html::before {
  content: '.html';
}

.pre:not(.tb).css::before {
  content: '.css';
}

.pre:not(.tb).js::before {
  content: '.js';
}

.pre:not(.tb):hover::before {
  content: 'Double click to copy |</>';
}

.pre:not(.tb).html:hover::before {
  content: 'Double click to copy | .html';
}

.pre:not(.tb).css:hover::before {
  content: 'Double click to copy | .css';
}

.pre:not(.tb).js:hover::before {
  content: 'Double click to copy | .js';
}

.pre[data-text]:not([data-text='']):not(.tb)::before {
  content: attr(data-text);
}

.pre[data-text]:not([data-text='']):not(.tb):hover::before {
  content: 'Double Click to Copy | ' attr(data-text);
}

/* Styles for code block without line numbers */
pre,
.cmC i[rel=pre] {
  display: block;
  position: relative;
  font-family: var(--fontC);
  font-size: 13px;
  line-height: 1.6em;
  border-radius: 3px;
  background: var(--synxBg);
  color: var(--synxC);
  padding: 30px 20px 20px;
  margin: 1.7em auto;
  -moz-tab-size: 2;
  tab-size: 2;
  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
  overflow: auto;
  direction: ltr;
  white-space: pre;
  max-height: 400px;
}

pre i {
  font-style: normal;
}

/* Styles for different types of code elements */
pre i.block {
  color: #fff;
  background: var(--synxBlue);
}

pre i.green {
  color: var(--synxGreen);
}

pre i.gray {
  color: var(--synxGray);
}

pre i.red {
  color: var(--synxOrange);
}

pre i.blue {
  color: var(--synxBlue);
}

/* Styles for inline code */
code {
  display: inline;
  padding: 5px;
  font-size: 14px;
  border-radius: 3px;
  line-height: inherit;
  color: var(--synxC);
  background: #f2f3f5;
  font-family: var(--fontC);
}

/* Styles for ::before pseudo-element in .pre */
.pre::before {
  color: var(--linkC);
}

Kelas Pre Css

  body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }

Kelas Pre

  body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
      pading {

        background-color: #ffffff;

        font-family: sans-serif;

      }

     h2{

        color: #000000;

        font-size: 2em;

      }

Kelas Pre html

  body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
   

Kelas Pre Css

  body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      
      h1 {
        color: #000000;
        font-size: 2em;
      }
      
      .container { 
      width: 500px; 
      margin: 0 auto;
      color: #ff0000; 
      }
      
      padding { 
      font-size: 16px;
      padding: 20px;
      }

Kelas Pre js

!function() {
  const post = document.querySelector('.post-body')[0],
    tx = post.innerText,
    wpm = 225,
    wd = tx.trim().split(/\s+/).length,
    tm = Math.ceil(wd / wpm);
  if (document.querySelector('.read-time')) {

    document.querySelector('.read-time i').innerText = tm;

  }
}();

cmC Pre i Normal Font

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {

        color: #000000;

        font-size: 2em;

      }

cmC pre i kelas Block

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
body{background-color:#ffffff;font-family:sans-serif}h1{color:#000000;font-size:2em}

Adding class block pre tag functions to blocking the coding between the code on the the elements

Pre i kelas green

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
      .container { 
      
      width: 500px; 
      margin: 0 auto;
      color: #ff0000; 
      }
      body { 
      
      font-size: 16px;
      padding: 20px;
      }
      

Pre i kelas gray

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }

Pre i kelas red

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }

Pre i kelas blue

 body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }

Syntax Warna warni Otomatis


body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
      .container { 
      
      width: 500px; 
      margin: 0 auto;
      color: #ff0000; 
      }
      body { 
      
      font-size: 16px;
      padding: 20px;
      }
      
      !function() {

  const post = document.querySelector('.post-body')[0],

    tx = post.innerText,

    wpm = 225,

    wd = tx.trim().split(/\s+/).length,

    tm = Math.ceil(wd / wpm);

  if (document.querySelector('.read-time')) {

    document.querySelector('.read-time i').innerText = tm;

  }

}();

MultiTab Syntax Highlighter

body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
body {
        background-color: #ffffff;
        font-family: sans-serif;
      }
      h1 {
        color: #000000;
        font-size: 2em;
      }
      .container { 
      
      width: 500px; 
      margin: 0 auto;
      color: #ff0000; 
      }
      body { 
      
      font-size: 16px;
      padding: 20px;
      }
!function() {

  const post = document.querySelector('.post-body')[0],

    tx = post.innerText,

    wpm = 225,

    wd = tx.trim().split(/\s+/).length,

    tm = Math.ceil(wd / wpm);

  if (document.querySelector('.read-time')) {

    document.querySelector('.read-time i').innerText = tm;

  }

}();

Cara Penggunaan

<div class="pre html"><!--html,css,js-->
<pre> <i class="blue"><!--block,green,gray,red,blue-->
Write Your Coding Content here!</i></pre>
    </div>

Baca Juga

About the Author

Andi Suardi Nasa
Salam Hangat | Teruslah Mengejar Keajaiban

Posting Komentar

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.