KB User's Guide - Syntax-highlighted Code Snippet Examples

This document provides examples of embedded code snippets in a KB document.

Bash/Shell

#!/usr/bin/env bash

set -euo pipefail

echo "Deploying application..."
docker compose up -d --build

C

#include <stdio.h>

int main(void) {
    printf("Hello, KB!\n");
    return 0;
}

C#

using System;

Console.WriteLine("Hello, KB!");

C++

#include <iostream>

int main() {
    std::cout << "Hello, KB!\n";
    return 0;
}

CSS

.notice {
  padding: 1rem;
  color: #123;
  background: #eef6ff;
  border-left: 4px solid #2b6cb0;
}

Go

package main

import "fmt"

func main() {
	name := "KB"
	fmt.Printf("Hello, %s!\n", name)
}

HTML

<article class="notice">
  <h2>Hello, KB authors!</h2>
  <p>Use <strong>semantic HTML</strong> when possible.</p>
</article>

JSON

{
  "service": "knowledge-base",
  "enabled": true,
  "languages": ["JSON", "Perl", "R", "Rust", "TypeScript"],
  "limits": {
    "maxResults": 25,
    "timeoutMs": 3000
  }
}

Java

public class Greeting {
    public static void main(String[] args) {
        System.out.println("Hello, KB!");
    }
}

JavaScript

const greeting = (name) => `Hello, ${name}!`;

document.querySelector("#message").textContent = greeting("KB");

Markdown

# Project Notes

Use **bold text** for key terms and `inline code` for commands.

## Checklist

- Review the documentation
- Run the test suite
- Deploy the update

[View the KnowledgeBase](https://kb.wisc.edu/)

Perl

use strict;
use warnings;

my @articles = ("Getting Started", "Troubleshooting", "API Reference");

for my $article (@articles) {
    print "Published: $article\n";
}

PHP

<?php

function greeting(string $name): string
{
    return "Hello, {$name}!";
}

echo greeting('KB');

Python

def greeting(name: str) -> str:
    return f"Hello, {name}!"

print(greeting("KB"))

R

scores <- c(82, 91, 76, 88, 95)

summary <- data.frame(
  average = mean(scores),
  highest = max(scores),
  passed = sum(scores >= 80)
)

print(summary)

Ruby

def greeting(name)
  "Hello, #{name}!"
end

puts greeting("KB")

Rust

fn main() {
    let topics = vec!["Setup", "Security", "Troubleshooting"];

    for topic in topics {
        println!("KB topic: {topic}");
    }
}

SQL

SELECT id, title, updated_at
FROM articles
WHERE status = 'published'
ORDER BY updated_at DESC
LIMIT 10;

TypeScript

interface Article {
  id: number;
  title: string;
  published: boolean;
}

const article: Article = {
  id: 42,
  title: "Configuring JSON syntax highlighting",
  published: true,
};

console.log(`Article #${article.id}: ${article.title}`);

XML

<?xml version="1.0" encoding="UTF-8"?>
<book id="42">
  <title>KnowledgeBase Guide</title>
  <author active="true">KB Team</author>
</book>

YAML

app:
  name: Knowledge Base
  version: 26.0.0
  environment: production

features:
  - insert_code_button
  - syntax_highlighting
  - multi_lingual



Keywords:
embedding formatted code highlighting languages Bash Shell script C++ csharp CSS HTML JSON Java JavaScript Markdown Perl PHP Python Ruby Rust TypeScript SQL XML 
Doc ID:
163314
Owned by:
Weizhong W. in KB User's Guide
Created:
2026-08-13
Updated:
2026-08-20
Sites:
KB User's Guide