Devopfreaks
Tutorials

Example: code blocks and syntax highlighting

[EXAMPLE] This post shows the supported languages for code blocks. Delete or replace before going live.

1 min read
Table of contents
  1. Bash
  2. Dockerfile
  3. YAML
  4. Terraform
  5. PHP
  6. Python
  7. JavaScript
  8. JSON

Code blocks start with three backticks followed by the language. Supported languages include:

Bash

#!/usr/bin/env bash
set -euo pipefail
for host in web-01 web-02; do
  ssh "$host" 'sudo systemctl status nginx --no-pager'
done

Dockerfile

FROM php:8.3-fpm-alpine
WORKDIR /var/www/html
COPY . .
RUN composer install --no-dev --optimize-autoloader

YAML

name: CI
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: php artisan test

Terraform

resource "hcloud_server" "web" {
  name        = "web-01"
  server_type = "cx22"
  image       = "debian-12"
}

PHP

Route::get('/health', fn () => response()->json(['status' => 'ok']));

Python

import json
print(json.dumps({"status": "ok"}, indent=2))

JavaScript

const res = await fetch('/up');
console.log(res.status);

JSON

{ "status": "ok", "checks": ["db", "cache"] }
Back to blog