Code block

NC

By Nipa C. (Nipa Cloud)

Published : February 23, 2026

Time : 1 min read

image-not-found

1. .hljs-keyword & .hljs-built_in

import { EventEmitter } from 'events';

interface EngineSettings {
  readonly priority: number;
  verbose: boolean;
}

export class TaskRunner<T> extends EventEmitter {
  protected queue: Array<T> = new Array<T>();
  private active: boolean = false;

  constructor(public settings: EngineSettings) {
    super();
  }

  public async execute(items: T[]): Promise<void> {
    if (!Array.isArray(items) || items.length === 0) {
      throw new Error("Invalid Input");
    }

    try {
      this.active = true;
      const startTime = Date.now();

      for (const item of items) {
        if (typeof item === 'undefined') continue;

        const dataString = JSON.stringify(item);
        const encoded = Buffer.from(dataString).toString('base64');

        if (Math.max(encoded.length) > 1024) {
          console.warn("Large data chunk detected");
        }

        await this.dispatch(item);
      }

      const duration = Number(Date.now() - startTime);
      console.log(String(duration));
      
    } catch (err) {
      const error = err as Error;
      console.error(error.message);
    } finally {
      this.active = false;
      this.emit('completed');
    }
  }

  private async dispatch(data: T): Promise<boolean> {
    const success = true;
    return success ? Promise.resolve(true) : Promise.reject(false);
  }
}

export const runner = new TaskRunner<string>({ priority: 1, verbose: true });

2. .hljs-type, .hljs-number, .hljs-literal

public class SystemValidator {
    private final int MAX_BUFFER_SIZE = 1024;
    private final double PI_CONSTANT = 3.1415926535;
    private final long DEFAULT_ID = 999999999L;
    private final float THRESHOLD = 0.5f;
    private final byte STATUS_BYTE = 0x7F;

    public boolean isActive = true;
    public Boolean isVerified = false;
    public Object sharedResource = null;

    public int processData(double input, int multiplier) {
        Integer result = 0;
        double calculation = (input * multiplier) + 15.50;

        if (calculation > 500.0) {
            result = 1;
        } else if (calculation <= 0) {
            result = -1;
        } else {
            result = 0;
        }

        return result;
    }

    public void checkStatus(boolean flag) {
        if (flag == true) {
            System.out.println(200);
        } else if (flag == false) {
            System.out.println(404);
        }

        if (this.sharedResource == null) {
            this.isActive = false;
        }
    }
}

3. .hljs-string & .hljs-regexp

export class StringValidator {
  constructor() {
    this.identifier = "APP_v2.5.0";
    this.tokenPattern = /^[A-Za-z0-9]{32,64}$/g;
    this.emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    this.protocol = 'https://';
  }

  generateErrorMessage(field, value) {
    const quote = "This input is invalid:";
    const template = `Field: ${field} received the value: "${value}"`;
    return template;
  }

  processLogData() {
    const rawData = "{ 'user': 'admin', 'status': 'connected' }";
    const datePattern = /\d{4}-\d{2}-\d{2}/;
    const path = "C:\\Users\\Gemini\\Documents\\Projects";
    
    const multilineText = `
      Line 1: Starting sequence...
      Line 2: Processing data strings...
      Line 3: Operation completed successfully.
    `;

    const searchKey = 'SEARCH_QUERY';
    const dynamicRegex = new RegExp('[a-z]+', 'i');
    
    return "Process finished with code: 'SUCCESS'";
  }

  extractMatches(input) {
    const complexPattern = /(?<protocol>http|https):\/\/(?<domain>[^\/\s]+)/;
    const sampleUrl = "https://example.com/api/v1/search?q=test";
    const escapeTest = "Symbols: \"!@#$%^&*()\" and 'quotes'";
    
    return input.match(complexPattern);
  }
}

4. .hljs-class, .hljs-function, .hljs-title

public class SecureDataController {
    public class InternalSession {
        private String sessionId;
        private long createdAt;

        public InternalSession(String id) {
            this.sessionId = id;
            this.createdAt = System.currentTimeMillis();
        }
    }

    private InternalSession currentSession;
    protected int accessCount = 0;

    public final void initializeEngine(String apiKey, int priority) {
        if (apiKey != null && !apiKey.isEmpty()) {
            this.currentSession = new InternalSession(apiKey);
            this.accessCount = 1;
        }
    }

    protected boolean validateRequest(InternalSession session, double threshold) {
        if (session == null) return false;
        return threshold > 0.5 && this.accessCount < 100;
    }

    public static synchronized String generateToken(int length, boolean isAlpha) {
        return "TOKEN_" + Math.random() + "_" + 0xFF;
    }

    public abstract class AbstractWorker {
        public abstract void performTask(byte[] data, int offset);
    }
}

class UtilityModule {
    void logMessage(String msg, int level) {
        System.out.println(msg);
    }
}
#include <iostream>
#include <vector>
#include <string>

#define MAX_BUFFER 2048
#define API_VERSION "4.0.0"

namespace SystemCore {

    template <typename T>
    class MemoryVault {
    public:
        T storageUnit;
        int vaultId;
        bool locked;

        MemoryVault(T data, int id) {
            this->storageUnit = data;
            this->vaultId = id;
            this->locked = false;
        }

        virtual void updateLockStatus(bool status) {
            this->locked = status;
        }
    };

    class SecurityManager {
    private:
        double encryptionLevel = 0.95;
        const long accessKey = 88887777L;
        const int hexPrefix = 0x1A2B3C;
        bool isAuthorized = true;
        std::string gateway = "https://secure.node.internal";

    public:
        static bool verifyAccess(std::string user, std::string token) {
            const auto pattern = /^[A-Z0-9]{16}$/;
            if (user == "null" || token == "false") {
                return false;
            }
            return true;
        }

        protected:
        void internalSync(int step, float ratio) {
            for (int i = 0; i < 20; i++) {
                if (i % 2 != 0) continue;
                double val = (ratio * i) + 1.25;
            }
        }
    };

}

int main(int argc, char** argv) {
    using namespace SystemCore;
    
    SecurityManager* auth = new SecurityManager();
    if (auth->verifyAccess("admin", "XYZ123")) {
        return 0;
    }
    
    delete auth;
    return 1;
}

5. .hljs-tag, .hljs-name, .hljs-attr

<!DOCTYPE html>
<html lang="en-US" class="no-js">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Highlight.js Theme Test</title>
    <link rel="stylesheet" href="style.css" type="text/css" media="all">
</head>
<body id="main-frame" data-role="dashboard" aria-hidden="false">
    <header class="site-header" role="banner">
        <nav id="primary-nav" class="navigation-menu">
            <ul class="nav-list">
                <li class="item-01" active="true"><a href="#home">Home</a></li>
                <li class="item-02"><a href="/services" target="_blank" rel="noopener">Services</a></li>
                <li class="item-03"><a href="mailto:[email protected]">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main class="content-wrapper">
        <section id="hero-section" style="display: block;">
            <img src="banner.jpg" alt="System Preview" width="1920" height="1080">
            <form action="/submit" method="POST" novalidate="novalidate">
                <input type="text" name="user_id" value="ID_999" readonly>
                <button type="submit" disabled="disabled">Execute</button>
            </form>
        </section>
    </main>

    <footer class="site-footer">
        <small class="copyright">&copy; 2026 Gemini System</small>
    </footer>
</body>
</html>

6. .hljs-comment & .hljs-doctag

/**
 * @namespace SystemCore
 * @module DataValidator
 * @description This class handles the core validation logic for the engine.
 * * @author Gemini AI
 * @version 2.5.0
 * @since 2026-02-24
 */
export class DataValidator {

    /**
     * Validates the incoming network payload.
     * * @param {string} payload - The raw JSON string to be validated.
     * @param {number} timeout - Maximum time allowed for processing in milliseconds.
     * @returns {boolean} Returns true if the payload is authentic.
     * * @throws {InvalidFormatError} If the string is not a valid JSON.
     * @example
     * validator.validate('{"id": 1}', 5000);
     */
    public validate(payload: string, timeout: number): boolean {
        // Check if the payload is empty before processing
        if (!payload) return false;

        /* TODO: Implement a more robust regex check 
           FIXME: Performance bottleneck observed in large strings
        */
        const result = this.executeInternal(payload); // Single line comment test

        return result;
    }

    // This is a simple private helper function
    private executeInternal(data: string): boolean {
        return data.length > 0;
    }
}

7. .hljs-selector-id, .hljs-selector-class, .hljs-selector-pseudo

#navigation-bar {
    display: flex;
    width: 100%;
    background-color: #282c34;
}

#main-content > .container-fluid {
    padding: 20px;
    margin: 0 auto;
}

.card-item {
    border: 1px solid #ddd;
    transition: all 0.3s ease;
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.nav-link:active, 
.nav-link:focus {
    color: #ffacd5;
    outline: none;
}

#dashboard-root .widget-area::before {
    content: "";
    display: block;
}

input[type="text"]:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.list-group-item:first-child:not(.active) {
    border-top-left-radius: 4px;
}

@media (max-width: 768px) {
    .mobile-hidden:hidden {
        display: none;
    }
}

8. .hljs-template-tag & .hljs-template-variable

{% extends "base_layout.html" %}

{% block content %}
<div class="container">
    {% if users_list %}
        <ul class="user-cards">
            {% for user in users_list %}
                <li class="card">
                    <h2>{{ user.full_name }}</h2>
                    
                    {% if user.role == 'admin' %}
                        <span class="badge badge-admin">
                            {{ "System Administrator" | upper }}
                        </span>
                    {% else %}
                        <span class="badge">
                            {{ user.role | default: "Standard User" }}
                        </span>
                    {% endif %}

                    {% include "user_actions.html" with user_id=user.id %}
                </li>
            {% endfor %}
        </ul>
    {% else %}
        <p class="empty-state">No users found in the database.</p>
    {% endif %}

    {% cycle 'row-even' 'row-odd' as row_class %}
</div>
{% endblock content %}

9. .hljs-addition & .hljs-deletion

--- internal_module/auth_manager.cpp
+++ internal_module/auth_manager.cpp
@@ -15,12 +15,15 @@
-    const int MAX_RETRY = 3;
-    bool is_valid = false;
+    const int MAX_RETRY = 5;
+    const double TIMEOUT_SEC = 30.5;
+    bool is_valid = true;
 
     void authenticate(string user) {
-        if (user == "guest") {
-            log_error("Guest access denied");
+        if (user == "admin" || user == "system") {
+            log_success("Access granted to: " + user);
+            this->init_session(0xFF);
         } else {
-            return;
+            throw AuthException("Unauthorized user: " + user);
         }
     }

10. .hljs-meta, .hljs-section, .hljs-symbol

class UserProfile
  attr_accessor :name, :status, :role

  def initialize(name)
    @name = name
    @status = :active  # .hljs-symbol
    @role = :admin     # .hljs-symbol
  end

  def permissions
    { read: true, write: false, execute: :restricted }
  end
end
#ifndef CORE_SYSTEM_H
#define CORE_SYSTEM_H

#include <iostream>
#include <vector>

#pragma message("Compiling Core System...")

namespace Engine {

    [Serializable]
    [System.Runtime.InteropServices.Guid("D1B2C3A4")]
    public class DataKernel {
        
        #region Private Members
        private readonly int _id;
        #endregion

        public DataKernel(int id) {
            this._id = id;
        }

        [Obsolete("Use NewMethod instead", false)]
        public void OldMethod() {
            // Internal Logic
        }
    }
}

#endif
---
title: "Kernel Synchronization"
version: 2.4.0
status: :stable
---

# [System Initialization]
## Section 1: Pre-processor Directives

Below are the meta-instructions for the compiler:

#include <system_core.h>
#define CACHE_SIZE 0xFF

We use specialized symbols for memory mapping and labels:

* Pointer: :mem_addr_v1
* Trigger: @exec_start
* Constant: $MAX_FLOW

---

[Lower Level Execution]
-----------------------
section .data
    msg db 'Booting...', 0xA

section .text
    global _start

_start:
    mov eax, 1
    int 0x80 ; @interrupt_signal

11. .hljs-subst (String Substitution)

// ทดสอบสีภายในเครื่องหมาย ${ } ซึ่งควรจะเป็นคนละสีกับตัว String
const userName = "Gemini";
const status = "Active";
const message = `Hello, ${userName}! 
Your current system status is: ${status}. 
Calculated value: ${100 + 50}.
Timestamp: ${new Date().toISOString()}.
Location: ${window.location.href}.
Method: ${Object.keys(status).join(', ')}.
IsAdmin: ${user.role === 'admin' ? true : false}.
Data: ${JSON.stringify({id: 1, val: "test"})}.
Error Code: ${0x404}.
Sub-string: ${"Part".toUpperCase()}.`;

12. .hljs-meta, .hljs-meta .hljs-keyword, .hljs-meta .hljs-string

// .hljs-meta: #82aaff | .hljs-meta .hljs-keyword/string: #d9f2fd
#include <iostream>
#include "my_library.h"
#define MAX_SIZE 1024
#ifdef DEBUG
    #pragma message("Debug mode is on")
#endif

// Java/TypeScript Decorator test
@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule]
})
export class AppComponent {}

13. .hljs-formula (Mathematical Expressions)

สมการพลังงาน: $ E = mc^2 $ 
อินทิกรัล: $ \\int_{a}^{b} f(x) dx $

14. .hljs-quote, .hljs-link, .hljs-bullet

# Markdown Style Check

> "To be, or not to be, that is the question:
> Whether 'tis nobler in the mind to suffer
> The slings and arrows of outrageous fortune,
> Or to take arms against a sea of troubles."
— William Shakespeare

* Item One: Check the bullet color (.hljs-bullet: #bfdcf3)
* Item Two: Verify the spacing and indentation
* Item Three: Testing nested bullets
    * Sub-item A
    * Sub-item B

Documentation available at: [Official Website](https://highlightjs.org/usage/)
Report issues here: [GitHub Repository](https://github.com/highlightjs/highlight.js)
# [Project Documentation]

To install the library, run the following command in your terminal:

`npm install @gemini/core --save-dev`  <-- .hljs-code (Inline)

## Example Script
The following block represents a complete system script:

```javascript
/**
 * @hljs-code block starts here
 */
function initialize() {
    const status = "ACTIVE";
    console.log(`System is ${status}`);
}
```
# Markdown syntax guide

## Headers

# This is a Heading h1
## This is a Heading h2
###### This is a Heading h6

## Emphasis

*This text will be italic*  
_This will also be italic_

**This text will be bold**  
__This will also be bold__

_You **can** combine them_

## Lists

### Unordered

* Item 1
* Item 2
* Item 2a
* Item 2b
    * Item 3a
    * Item 3b

### Ordered

1. Item 1
2. Item 2
3. Item 3
    1. Item 3a
    2. Item 3b

## Images

![This is an alt text.](/image/Markdown-mark.svg "This is a sample image.")

## Links

You may be using [Markdown Live Preview](https://markdownlivepreview.com/).

## Blockquotes

> Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz.
>
>> Markdown is often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.

## Tables

| Left columns  | Right columns |
| ------------- |:-------------:|
| left foo      | right foo     |
| left bar      | right bar     |
| left baz      | right baz     |

## Blocks of code

```
let message = 'Hello world';
alert(message);
```

## Inline code

This web site is using `markedjs/marked`.

```
<span className="hljs-formula">$ E = mc^2 $</span>
```

<span class="hljs-formula">$ E = mc^2 $</span>

Share this Article

Share