scribble-tools
1 Guide
1.1 Inline Forms
1.2 Block Forms
1.3 Block Form Decorations
1.4 Preview Visualizations
1.5 Escapes
1.6 Documentation Links
2 Reference
2.1 Inline Forms
css-code
html-code
js-code
shell-code
wasm-code
scribble-code
2.2 Block Forms
cssblock
cssblock0
htmlblock
htmlblock0
jsblock
jsblock0
shellblock
shellblock0
wasmblock
wasmblock0
current-wasm-docs-source
current-scribble-shell
current-shell-docs-source
current-scribble-context
scribbleblock
scribbleblock0
2.3 Preview Legend
2.4 MDN Maps
mdn-map-path
mdn-default-map-entries
mdn-entry?
mdn-install-map!
mdn-reset-map!
mdn-export-default-map!
3 Extended Examples
3.1 CSS
3.2 HTML
3.3 Java  Script
3.4 Shell
3.5 Web  Assembly
3.6 Scribble
9.1

scribble-tools🔗ℹ

Jens Axel Søgaard <jensaxel@soegaard.net>

This library provides Scribble forms for typesetting CSS, HTML, JavaScript, shell scripts (Bash/Zsh/PowerShell), WebAssembly (WAT), and Scribble snippets with syntax coloring.

The inline forms (css-code, html-code, js-code, shell-code, wasm-code, and scribble-code) produce content.

The block forms (cssblock, htmlblock, jsblock, shellblock, wasmblock, and scribbleblock) produce code blocks with optional line numbers, file labels, and escapes.

1 Guide🔗ℹ

This section gives a practical introduction to the forms and the most useful options.

1.1 Inline Forms🔗ℹ

Use inline forms when you want code inside running text:

Language

  

Scribble Form

CSS

  

@css-code{.card { color: #c33; }}

HTML

  

@html-code{<button class="primary">Save</button>}

JavaScript

  

@js-code{const total = items.reduce((a, b) => a + b, 0);}

Shell

  

@shell-code[#:shell 'bash]{if [ -f ~/.zshrc ]; then echo ok; fi}

WebAssembly

  

@wasm-code{(module (func (result i32) (i32.const 42)))}

Scribble

  

@scribble-code{"@bold{Hello} world."}

Language

  

Result

CSS

  

.card { color: #c33;  }

HTML

  

<button class="primary">Save</button>

JavaScript

  

const total = items.reduce((a, b) => a + b, 0);

Shell

  

if [ -f ~/.zshrc ]; then echo ok; fi

WebAssembly

  

(module (func (result i32) (i32.const 42)))

Scribble

  

@bold{Hello} world.

If you want scribble-code to link identifiers to their documentation, you need to provide a context. Either add "#:context #'here" when calling scribble-code, or set the context using a parameter:

@current-scribble-context[#'here]
@scribble-code["@bold{Hello} world."]

@bold{Hello} world.

1.2 Block Forms🔗ℹ

Use block forms for larger snippets:

CSS form

Scribble source

@cssblock{
/* Accent color */
.card {
  color: #c33;
  border-radius: 12px;
}
}
 

   

Rendered result

/* Accent color */
.card {
  color: #c33;
  border-radius: 12px;
}

HTML form

Scribble source

@htmlblock{
<!-- Hero title -->
<main>
  <h1>Hello</h1>
  <p>Welcome</p>
</main>
}
 

   

Rendered result

<!-- Hero title -->
<main>
  <h1>Hello</h1>
  <p>Welcome</p>
</main>

JavaScript form

Scribble source

@jsblock{
/* loadData :: () => Promise<any> */
async function loadData() {
  const r = await fetch("/api/data");
  return r.json();
}
}
 

   

Rendered result

/* loadData :: () => Promise<any> */
async function loadData() {
  const r = await fetch("/api/data");
  return r.json();
}

WebAssembly form

Scribble source

@wasmblock{
;; A simple module
(module
  (func $fortytwo (result i32)
    i32.const 42))
}
 

   

Rendered result

;; A simple module
(module
  (func $fortytwo (result i32)
    i32.const 42))

Shell form

Scribble source

@shellblock[#:shell 'zsh]{
# zsh bootstrap
setopt prompt_subst
autoload -Uz compinit
compinit
}
 

   

Rendered result

# zsh bootstrap
setopt prompt_subst
autoload -Uz compinit
compinit

Scribble form

Scribble source

@scribbleblock[#:context #'here]{
  @@section{Greeting}
  @@bold{Hello}, Scribble!
}
 

   

Rendered result

@section{Greeting}
@bold{Hello}, Scribble!
 

1.3 Block Form Decorations🔗ℹ

Use these options to add decorations to block output:

Scribble source

   

Rendered result

Line numbers

@cssblock[#:line-numbers 1]{
.card {
  color: #c33;
}
}
 

   

Rendered result

1 .card {
2   color: #c33;
3 }

File name

@cssblock[#:file "styles.css"]{
.card {
  color: #c33;
}
}
 

   

Rendered result

"styles.css"

.card {
  color: #c33;
}

Line numbers + file name

@cssblock[#:line-numbers 1 #:file "styles.css"]{
.card {
  color: #c33;
}
}
 

   

Rendered result

"styles.css"

1 .card {
2   color: #c33;
3 }

1.4 Preview Visualizations🔗ℹ

css-code and cssblock can show visual helpers:

.badge {
  color: #0a7;
  background: linear-gradient(90deg, #0a7, #5cf);
  font-family: "Fira Code", monospace;Aa
  margin: 16px;
  border-radius: 4px;
  border-radius: 8px;
}

1.5 Escapes🔗ℹ

All forms support escapes to splice Scribble content:

Scribble source

@cssblock[#:escape unq
          ".notice { color: "
          (unq (bold "tomato"))
          "; }"]
 

Rendered result

.notice { color: tomato; }

1.6 Documentation Links🔗ℹ

By default, code output includes documentation links for common identifiers:

2 Reference🔗ℹ

This section documents each form and procedure in detail.

2.1 Inline Forms🔗ℹ

syntax

(css-code maybe-option ... str-expr ...+)

 
maybe-option = 
  | #:color-swatch? color-swatch?-expr
  | #:font-preview? font-preview?-expr
  | #:dimension-preview? dimension-preview?-expr
  | #:mdn-links? mdn-links?-expr
  | #:preview-mode preview-mode-expr
  | #:preview-tooltips? preview-tooltips?-expr
  | #:preview-css-url preview-css-url-expr
  | #:escape escape-id
Typesets the concatenated strings as inline CSS code. Newlines and surrounding whitespace are collapsed to single spaces.

#:color-swatch? controls whether detected CSS color literals are followed by a small color swatch (default: #t). Gradient literals (for example linear-gradient (...)) are shown as a small bar swatch.

#:font-preview? controls whether font-family declarations are followed by a small Aa preview in the selected font (default: #t).

#:dimension-preview? controls whether spacing and radius declarations such as margin, padding, gap, and border-radius get tiny inline visualizers (default: #t).

#:mdn-links? controls whether common CSS tokens are wrapped as hyperlinks to MDN documentation (default: #t).

#:preview-mode controls when previews are shown: 'always, 'hover, or 'none (default: 'always).

#:preview-tooltips? controls whether preview decorations expose tooltips (hover/focus) and related runtime tooltip behavior (default: #t).

#:preview-css-url optionally points to an external stylesheet for preview UI classes. When provided, the runtime loads that stylesheet instead of injecting inline preview CSS.

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

Example: h1 { color: #c33;  }

syntax

(html-code maybe-escape str-expr ...+)

 
maybe-escape = 
  | #:mdn-links? mdn-links?-expr
  | #:escape escape-id
Typesets the concatenated strings as inline HTML code. Newlines and surrounding whitespace are collapsed to single spaces.

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

#:mdn-links? controls whether common HTML tokens are wrapped as hyperlinks to MDN documentation, including CSS and JavaScript tokens that appear inside <style> and <script> sections (default: #t).

Example: <em class="note">Hi</em>

syntax

(js-code maybe-escape str-expr ...+)

 
maybe-escape = 
  | #:jsx? jsx?-expr
  | #:mdn-links? mdn-links?-expr
  | #:escape escape-id
Typesets the concatenated strings as inline JavaScript code. Newlines and surrounding whitespace are collapsed to single spaces.

#:jsx? enables JSX-aware tokenization for snippets that contain embedded tags (default: #f).

#:mdn-links? controls whether common JavaScript tokens are wrapped as hyperlinks to MDN documentation (default: #t).

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

Example: const n = 42;

syntax

(shell-code maybe-options str-expr ...+)

 
maybe-options = 
  | #:shell shell-expr
  | #:docs-source docs-source-expr
  | #:escape escape-id
Typesets the concatenated strings as inline shell code. Newlines and surrounding whitespace are collapsed to single spaces.

#:shell selects shell flavor: 'bash, 'zsh, 'powershell, or 'pwsh. Default: (current-scribble-shell).

#:docs-source selects where shell documentation links point: 'auto, 'bash, 'zsh, 'powershell, 'posix, or 'none. Default: (current-shell-docs-source). When the effective value is 'auto, links follow the effective shell: 'bash when #:shell (or current-scribble-shell) is 'bash, 'zsh when it is 'zsh, and 'powershell when it is 'powershell or 'pwsh.

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

Example: if [ -f ~/.zshrc ]; then echo ok; fi

syntax

(wasm-code maybe-escape str-expr ...+)

 
maybe-escape = 
  | #:docs-source docs-source-expr
  | #:escape escape-id
Typesets the concatenated strings as inline WebAssembly text (WAT) code. Newlines and surrounding whitespace are collapsed to single spaces.

#:docs-source selects where WebAssembly documentation links point: 'wasm-spec-3.0, 'mdn, or 'none. The default comes from current-wasm-docs-source, which defaults to 'wasm-spec-3.0.

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

Example: (module (func (result i32) (i32.const 42)))

syntax

(scribble-code maybe-options str-expr ...+)

 
maybe-options = 
  | #:context context-expr
  | #:escape escape-id
Typesets the concatenated strings as inline Scribble source code. Newlines and surrounding whitespace are collapsed to single spaces.

#:context supplies syntax context for identifier link resolution (default: (current-scribble-context)). Recommended: use #'here when you want identifiers in a snippet to resolve against the current manual’s for-label imports.

An optional #:escape identifier configures escapes of the form (escape-id expr) to splice expr-produced elements into the typeset output.

Example: @bold{Hi} there.

2.2 Block Forms🔗ℹ

syntax

(cssblock option ... str-expr ...+)

 
option = #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:copy-button? copy-button?-expr
  | #:color-swatch? color-swatch?-expr
  | #:font-preview? font-preview?-expr
  | #:dimension-preview? dimension-preview?-expr
  | #:mdn-links? mdn-links?-expr
  | #:preview-mode preview-mode-expr
  | #:preview-tooltips? preview-tooltips?-expr
  | #:preview-css-url preview-css-url-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
Typesets CSS as a block inset using 'code-inset. Options:

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:color-swatch? controls whether detected CSS color literals are followed by a small swatch; gradient literals are shown as a small bar (default: #t).

  • #:font-preview? controls whether font-family declarations are followed by a small Aa preview (default: #t).

  • #:dimension-preview? controls whether spacing and radius declarations (for example margin, padding, gap, letter-spacing, text-indent, filter: blur (...), and border-radius) are followed by small visualizer decorations (default: #t).

  • #:mdn-links? controls whether common CSS tokens are wrapped as hyperlinks to MDN documentation (default: #t).

  • #:preview-mode controls when previews are shown: 'always, 'hover, or 'none (default: 'always).

  • #:preview-tooltips? controls whether preview decorations include tooltip text and interactive hover/focus tooltip UI (default: #t).

  • #:preview-css-url optionally points to an external stylesheet URL/path for preview classes; when set, runtime links that stylesheet instead of injecting inline preview CSS (default: #f).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

1 .card {
2   color: #c33;
3 }

syntax

(cssblock0 option ... str-expr ...+)

Like cssblock, but without the inset wrapper.

Example:

  .compact {
    color: #444;
  }

syntax

(htmlblock option ... str-expr ...+)

 
option = #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:copy-button? copy-button?-expr
  | #:mdn-links? mdn-links?-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
Typesets HTML as a block inset using 'code-inset. Options:

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:mdn-links? controls whether common HTML tokens are wrapped as hyperlinks to MDN documentation, including CSS and JavaScript tokens that appear inside <style> and <script> sections (default: #t).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

"snippet.html"

<main>
  <p>Example</p>
</main>

syntax

(htmlblock0 option ... str-expr ...+)

Like htmlblock, but without the inset wrapper.

Example:

  <ul>
    <li>One</li>
    <li>Two</li>
  </ul>

syntax

(jsblock option ... str-expr ...+)

 
option = #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:copy-button? copy-button?-expr
  | #:jsx? jsx?-expr
  | #:mdn-links? mdn-links?-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
Typesets JavaScript as a block inset using 'code-inset. Options:

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:jsx? enables JSX-aware tokenization for snippets containing embedded tags (default: #f).

  • #:mdn-links? controls whether common JavaScript tokens are wrapped as hyperlinks to MDN documentation (default: #t).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

console.log("escaped");

syntax

(jsblock0 option ... str-expr ...+)

Like jsblock, but without the inset wrapper.

Example:

  let total = 0;
  for (const n of [1, 2, 3]) {
    total += n;
  }

syntax

(shellblock option ... str-expr ...+)

 
option = #:shell shell-expr
  | #:docs-source docs-source-expr
  | #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:copy-button? copy-button?-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
Typesets shell source as a block inset using 'code-inset. Options:

  • #:shell selects shell flavor: 'bash, 'zsh, 'powershell, or 'pwsh. Default: (current-scribble-shell).

  • #:docs-source selects link targets: 'auto, 'bash, 'zsh, 'powershell, 'posix, or 'none. Default: (current-shell-docs-source). With 'auto, links follow the effective shell selected by #:shell (or current-scribble-shell).

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

1 # build step
2 if [ -f ./configure ]; then
3   ./configure && make
4 fi

syntax

(shellblock0 option ... str-expr ...+)

Like shellblock, but without the inset wrapper.

Example:

  setopt prompt_subst
  autoload -Uz compinit
  compinit

syntax

(wasmblock option ... str-expr ...+)

 
option = #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:copy-button? copy-button?-expr
  | #:docs-source docs-source-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
Typesets WebAssembly text (WAT) as a block inset using 'code-inset. Options:

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:docs-source selects WebAssembly link targets: 'wasm-spec-3.0, 'mdn, or 'none. Default: (current-wasm-docs-source).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

1 (module
2   (func (result i32)
3     i32.const 42))

syntax

(wasmblock0 option ... str-expr ...+)

Like wasmblock, but without the inset wrapper.

Example:

  (module
    (func (result i32)
      i32.const 7))

parameter

(current-wasm-docs-source)  (or/c 'wasm-spec-3.0 'mdn 'none)

(current-wasm-docs-source src)  void?
  src : (or/c 'wasm-spec-3.0 'mdn 'none)
Controls the default documentation source used by wasm-code, wasmblock, and wasmblock0 when #:docs-source is not provided. The default value is 'wasm-spec-3.0.

parameter

(current-scribble-shell)  (or/c 'bash 'zsh 'powershell 'pwsh)

(current-scribble-shell sh)  void?
  sh : (or/c 'bash 'zsh 'powershell 'pwsh)
Controls the default shell flavor used by shell-code, shellblock, and shellblock0 when #:shell is not provided. The default value is 'bash.

parameter

(current-shell-docs-source)

  (or/c 'auto 'bash 'zsh 'powershell 'pwsh 'posix 'none)
(current-shell-docs-source src)  void?
  src : (or/c 'auto 'bash 'zsh 'powershell 'pwsh 'posix 'none)
Controls the default shell documentation source used by shell-code, shellblock, and shellblock0 when #:docs-source is not provided. The default value is 'auto, which means: use Bash docs when the effective shell is 'bash, Zsh docs when the effective shell is 'zsh, and PowerShell docs when the effective shell is 'powershell (or 'pwsh). To force one source regardless of shell selection, use 'bash, 'zsh, 'powershell, 'posix, or 'none.

parameter

(current-scribble-context)  (or/c #f syntax?)

(current-scribble-context ctx)  void?
  ctx : (or/c #f syntax?)
Controls the default syntax context used by scribble-code, scribbleblock, and scribbleblock0 when #:context is not provided. The default value is #f.

syntax

(scribbleblock option ... str-expr ...+)

 
option = #:indent indent-expr
  | #:line-numbers line-number-expr
  | #:line-number-sep line-number-sep-expr
  | #:lang lang-expr
  | #:context context-expr
  | #:copy-button? copy-button?-expr
  | #:file filename-expr
  | #:escape escape-id
 
  indent-expr : exact-nonnegative-integer?
  line-number-expr : (or/c #f exact-nonnegative-integer?)
  line-number-sep-expr : exact-nonnegative-integer?
  lang-expr : string?
  context-expr : (or/c #f syntax?)
Typesets Scribble source as a block inset using 'code-inset.

The most important option is #:context. If provided identifiers will be linked to their documentation entries. If you are using the same context several times, it can be convenient to set the parameter current-scribble-context instead of using #:context repeatedly.

Options:

  • #:indent controls left indentation in spaces (default: 0).

  • #:line-numbers enables line numbers when not #f, using the given start number (default: #f).

  • #:line-number-sep controls the spacing between the line number and code (default: 1).

  • #:lang chooses the language line used for parsing/linking when the snippet itself does not start with #lang (default: "scribble/manual").

  • #:context supplies syntax context for identifier link resolution (default: (current-scribble-context)). Recommended: use #'here when you want identifiers in a snippet to resolve against the current manual’s for-label imports.

  • #:copy-button? controls whether a copy icon appears on hover/focus to copy the block text to the clipboard (default: #t).

  • #:file wraps the result in filebox with filename-expr as label (default: #f, i.e. no file label).

  • #:escape changes the escape identifier; subforms of the shape (escape-id expr) splice expr as content (default escape id: unsyntax).

Example:

2 @title{Small Example}
3 This is @bold{Scribble} source.
4  

syntax

(scribbleblock0 option ... str-expr ...+)

Like scribbleblock, but without the inset wrapper.

Example:

  @itemlist[
   @item{Alpha}
   @item{Beta}
  ]
   

2.3 Preview Legend🔗ℹ

Rendered legend example:

.legend {
  color: #c33;
  background: linear-gradient(90deg, red, blue);
  margin: 4px;
  margin: 12px;
  margin: 28px;
  filter: blur(2px);
  filter: blur(8px);
  filter: blur(18px);
  border-radius: 2px;
  border-radius: 6px;
  border-radius: 9px;
  font-family: "Fira Code", monospace;Aa
  font-family: "Georgia", serif;Aa
  font-family: "Helvetica Neue", Arial, sans-serif;Aa
}

  • Color square: a detected color literal such as #c33 or red.

  • Gradient bar: a detected gradient literal such as linear-gradient (...).

  • Spacing bar: detected spacing-sized values (for example margin, gap, letter-spacing, or filter: blur (...)) scaled to a compact width.

  • Radius chip: detected border-radius values, where the chip corner radius mirrors the declaration.

  • Font Aa: preview of font-family, including fallback resolution tooltip and missing-font warning.

2.4 MDN Maps🔗ℹ

MDN maps control which CSS/HTML/JavaScript/WebAssembly identifiers become links to the MDN documentation site. The procedures below let you inspect the active map, install overrides, reset to defaults, and export the bundled entries. Most users will not need these tools, but they are useful when you want to add links that are not covered by the default maps.

procedure

(mdn-map-path)  path?

Returns the user override map path used by #:mdn-links? in CSS/HTML/JavaScript forms. If the file exists, entries in it override bundled defaults.

procedure

(mdn-default-map-entries)

  (listof (list/c symbol? symbol? string? string?))
Returns bundled compact default entries as (list lang class token url-or-path) records. In addition to explicit entries, the resolver also supports implicit coverage for all CSS property names (Web/CSS/<property>), all known HTML element tags (Web/HTML/Element/<tag>), and common WebAssembly instruction families (WebAssembly/Reference/...).

procedure

(mdn-entry? v)  boolean?

  v : any/c
Recognizes one map entry record.

procedure

(mdn-install-map! entries-or-path)  path?

  entries-or-path : 
(or/c path-string?
      (listof (list/c symbol? symbol? string? string?)))
Installs a user override map. You can pass either a list of entries or the path to a .rktd file containing such a list.

procedure

(mdn-reset-map!)  boolean?

Deletes the user override map (if present), reverting to bundled defaults. Returns #t when a file was removed.

procedure

(mdn-export-default-map! dest)  path-string?

  dest : path-string?
Writes bundled defaults to dest as a .rktd file so it can be edited and re-installed with mdn-install-map!.

Command-line helper:

racket -l scribble-tools/mdn-map-tool -- --path

racket -l scribble-tools/mdn-map-tool -- --export-default mdn-map.rktd

racket -l scribble-tools/mdn-map-tool -- --build-default mdn-map-built.rktd

racket -l scribble-tools/mdn-map-tool -- --install mdn-map.rktd

racket -l scribble-tools/mdn-map-tool -- --update-from mdn-map-custom.rktd

racket -l scribble-tools/mdn-map-tool -- --reset

Map build pipeline (dedupe + optional merge):

racket -l scribble-tools/mdn-map-build -- --stats

racket -l scribble-tools/mdn-map-build -- --out mdn-map-built.rktd

racket -l scribble-tools/mdn-map-build -- --merge mdn-map-custom.rktd --out mdn-map-merged.rktd

racket -l scribble-tools/mdn-map-build -- --merge mdn-map-custom.rktd --install

3 Extended Examples🔗ℹ

This chapter provides longer rendered examples for each supported language. Each block uses line numbers and a file label to make lexer behavior and documentation links easier to inspect.

3.1 CSS🔗ℹ

"extended/styles.css"

 1 :root {
 2   --brand: #0b62a3;
 3   --accent: oklch(66% 0.18 28);
 4 }
 5 
 6 .layout {
 7   display: grid;
 8   grid-template-columns: 240px 1fr;
 9   gap: clamp(0.75rem, 2vw, 1.5rem);
10   margin: 16px;
11   border-radius: 9px;
12   background: linear-gradient(90deg, #f6f8fb, #eef3ff);
13 }
14 
15 .button {
16   color: white;
17   background: color-mix(in srgb, var--brand(--brand) 80%, black);
18   border: 1px solid #0a4f83;
19   padding: 0.5rem 0.8rem;
20   font-family: "Fira Code", "JetBrains Mono", monospace;Aa
21 }

3.2 HTML🔗ℹ

"extended/index.html"

 1 <!doctype html>
 2 <html lang="en">
 3   <head>
 4     <meta charset="utf-8">
 5     <title>Extended Example</title>
 6     <style>
 7       .hero { color: #c33;  margin: 12px;  }
 8       .hero em { font-family: "Georgia", serif;Aa }
 9     </style>
10   </head>
11   <body>
12     <main id="app">
13       <h1 class="hero">Hello <em>world</em></h1>
14       <button type="button" data-role="save">Save</button>
15     </main>
16     <script>
17       const root = document.querySelector("#app");
18       if (root) root.setAttribute("data-ready", "yes");
19     </script>
20   </body>
21 </html>

3.3 JavaScript🔗ℹ

"extended/app.js"

 1 function quickSort(xs, cmp = (a, b) => a - b) {
 2   if (xs.length <= 1) return xs.slice();
 3   const [pivot, ...rest] = xs;
 4   const left = [];
 5   const right = [];
 6   for (const x of rest) {
 7     if (cmp(x, pivot) < 0) left.push(x); else right.push(x);
 8   }
 9   return [...quickSort(left, cmp), pivot, ...quickSort(right, cmp)];
10 }
11 
12 function renderNumbers(listEl, numbers) {
13   listEl.textContent = "";
14   for (const n of numbers) {
15     const li = document.createElement("li");
16     li.textContent = String(n);
17     listEl.append(li);
18   }
19 }
20 
21 function parseInput(inputEl) {
22   return inputEl.value
23     .split(/[\\s,]+/)
24     .map((s) => s.trim())
25     .filter(Boolean)
26     .map(Number)
27     .filter((n) => Number.isFinite(n));
28 }
29 
30 function boot() {
31   const inputEl = document.querySelector("#numbers");
32   const buttonEl = document.querySelector("#sort");
33   const listEl = document.querySelector("#result");
34   if (!inputEl || !buttonEl || !listEl) return;
35 
36   buttonEl.addEventListener("click", () => {
37     const data = parseInput(inputEl);
38     const sorted = quickSort(data);
39     renderNumbers(listEl, sorted);
40   });
41 }
42 
43 boot();

3.4 Shell🔗ℹ

This utility copies one directory tree to another and validates arguments before running the copy operation.

"extended/copy-tree.sh"

 1 #!/usr/bin/env bash
 2 set -euo pipefail
 3 
 4 usage() {
 5   echo "usage: $0 <source-dir> [dest-dir]"
 6 }
 7 
 8 copy_tree() {
 9   local src="$1"
10   local dst="$2"
11   mkdir -p "$dst"
12   cp -R "$src"/. "$dst"/
13 }
14 
15 main() {
16   if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
17     usage
18     return 2
19   fi
20   local src="$1"
21   local dst="${2:-./out}"
22   if [ ! -d "$src" ]; then
23     echo "error: source directory not found: $src" >&2
24     return 1
25   fi
26   copy_tree "$src" "$dst"
27   echo "copied $src -> $dst"
28 }
29 
30 main "$@"

3.5 WebAssembly🔗ℹ

"extended/module.wat"

 1 (module
 2   (memory (export "mem") 1)
 3   (func $sum_to_acc (param $i i32) (param $n i32) (param $acc i32) (result i32)
 4     (if (result i32) (i32.le_s (local.get $i) (local.get $n))
 5       (then
 6         (call $sum_to_acc
 7           (i32.add (local.get $i) (i32.const 1))
 8           (local.get $n)
 9           (i32.add (local.get $acc) (local.get $i))))
10       (else
11         (local.get $acc))))
12   (func (export "sum_to") (param $n i32) (result i32)
13     (call $sum_to_acc (i32.const 0) (local.get $n) (i32.const 0))))

3.6 Scribble🔗ℹ

"extended/guide.scrbl"

 2 @title{Extended Scribble Example}
 3 @section{Overview}
 4 This paragraph includes @bold{inline formatting},
 5 @italic{emphasis}, and @racket[code] references.
 6 @itemlist[
 7   @item{First point}
 8   @item{Second point}
 9   @item{Third point}
10 ]
11 @subsection{Details}
12 See @secref["reference-inline-forms"] for inline forms.
13