Get Moduly free
Gutenberg · Content & Layout · live demoSource CodeShow readable, copyable code samples in tutorials.

Source Code

The core Code block shows monospace text in one colour. This block highlights the syntax of 26 languages on the server (so it is coloured without any script and never runs code), and adds a copy button, download, several files in tabs, line numbers starting anywhere, highlighted lines, diff colours, a “show more” for long code, eight themes and a caption. It converts to and from the core Code and Preformatted blocks.

Ready-made patterns

Inserter → Patterns → Moduly.

Fetch with a timeout

Abort a request that takes too long — the highlighted lines do the work.

fetch-timeout.jsJavaScript
// Give up after `ms` milliseconds.export async function fetchWithTimeout( url, ms = 5000 ) {	const controller = new AbortController();	const timer = setTimeout( () => controller.abort(), ms );	try {		const res = await fetch( url, { signal: controller.signal } );		return await res.json();	} finally {		clearTimeout( timer );	}}
Works in every modern browser and in Node 18+.

A toggle button

HTML / XML
<button class="toggle" aria-pressed="false">  Dark mode</button>

What changed

checkout.phpDiff
@@ -12,7 +12,8 @@ function shipping_cost( $cart ) {-	if ( $cart->total > 50 ) {+	$free_from = (float) get_option( 'free_shipping_from', 50 );+	if ( $cart->total >= $free_from ) { 		return 0; 	} 	return 4.95;

Eight themes

Midnight

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Daylight

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Monokai

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Dracula

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Nord

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Solarized light

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

GitHub light

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Synthwave

functions.phpPHP
<?php// Register a custom post type.add_action( 'init', function () {	register_post_type( 'book', [		'label'  => __( 'Books', 'my-theme' ),		'public' => true,	] );} );

Languages

Python

stats.pyPython
from statistics import mean @cachedef average(values: list[float]) -> float:    """Return the mean, or 0 for an empty list."""    return mean(values) if values else 0.0 print(average([3, 4, 5]))  # 4

SQL

top-customers.sqlSQL
SELECT c.name, SUM(o.total) AS spentFROM customers cJOIN orders o ON o.customer_id = c.idWHERE o.created_at >= '2026-01-01'GROUP BY c.nameORDER BY spent DESCLIMIT 10;

Bash

deploy.shBash / Shell
#!/usr/bin/env bashset -euo pipefail for site in blog shop docs; do  echo "Deploying $site…"  rsync -az ./dist/$site/ "deploy@example.com:/var/www/$site"done

JSON

package.jsonJSON
{  "name": "my-shop",  "version": "1.4.0",  "private": true,  "scripts": { "build": "vite build" }}

Rust

main.rsRust
fn main() {    let items = vec![3, 1, 2];    let total: i32 = items.iter().sum();    println!("Total: {}", total);}

YAML

docker-compose.ymlYAML
services:  db:    image: mariadb:11    environment:      MARIADB_ROOT_PASSWORD: secret # change me    ports:      - "3306:3306"

Options

Collapsed after 8 lines

config.phpPHP
<?phpreturn [	'option_1' => 'value',	'option_2' => true,	'option_3' => true,	'option_4' => 'value',	'option_5' => true,	'option_6' => true,	'option_7' => 'value',	'option_8' => true,	'option_9' => true,	'option_10' => 'value',	'option_11' => true,	'option_12' => true,	'option_13' => 'value',	'option_14' => true,	'option_15' => true,	'option_16' => 'value',	'option_17' => true,	'option_18' => true,	'option_19' => 'value',	'option_20' => true,	'option_21' => true,	'option_22' => 'value',	'option_23' => true,	'option_24' => true,	'option_25' => 'value',	'option_26' => true,	'option_27' => true,	'option_28' => 'value',	'option_29' => true,	'option_30' => true,];

Maximum height 220 px (scrolls)

config.phpPHP
<?phpreturn [	'option_1' => 'value',	'option_2' => true,	'option_3' => true,	'option_4' => 'value',	'option_5' => true,	'option_6' => true,	'option_7' => 'value',	'option_8' => true,	'option_9' => true,	'option_10' => 'value',	'option_11' => true,	'option_12' => true,	'option_13' => 'value',	'option_14' => true,	'option_15' => true,	'option_16' => 'value',	'option_17' => true,	'option_18' => true,	'option_19' => 'value',	'option_20' => true,	'option_21' => true,	'option_22' => 'value',	'option_23' => true,	'option_24' => true,	'option_25' => 'value',	'option_26' => true,	'option_27' => true,	'option_28' => 'value',	'option_29' => true,	'option_30' => true,];

Line numbers from 120 · highlight 121-122

excerpt.jsJavaScript
if ( cart.items.length === 0 ) {	showEmptyState();	return;}renderTotals( cart );

Long lines wrapped · no numbers

notes.mdMarkdown
# Release notes This release makes the checkout faster by loading the payment form only when it is needed, which saves roughly 180 kB of JavaScript on the first page view for most visitors. - **Fixed:** coupon codes with spaces- `npm run build` is now twice as fast

No header · icon-only copy and download float

:root {  --neon: #ff7edb;}h1 { color: var(--neon); text-shadow: 0 0 8px currentColor; }

Grey dots · no language · radius 4 · 16 px

.env
# Local settingsAPP_ENV=localAPP_DEBUG=trueDB_HOST=127.0.0.1

Wide, with four files and a caption

PHP
<?php/** * Plugin Name: My Plugin */add_action( 'wp_enqueue_scripts', function () {	wp_enqueue_script( 'my-plugin', plugins_url( 'app.js', __FILE__ ), [], '1.0', true );} );
A tiny WordPress plugin: PHP, JS, CSS and its readme.