example - speced/respec GitHub Wiki

.example

Marks a <pre>, <aside>, or other element as a numbered example. Adds an "Example N" heading with an optional title.

Usage

<pre class="example">
  const result = navigator.credentials.get({ password: true });
</pre>
<aside class="example" title="Using the Fetch API">
  <p>Here is how to make a request:</p>
  <pre>
    const res = await fetch("/data.json");
  </pre>
</aside>
<pre class="illegal-example">
  document.write("&lt;!-- don't do this --&gt;");
</pre>

Notes

  • Examples are numbered automatically ("Example 1", "Example 2", โ€ฆ)
  • A self-link (ยง) is generated so readers can link directly to a specific example
  • The title attribute is interpreted as HTML โ€” see title attributes
  • Use class="illegal-example" to mark a counter-example (renders with a different style)
  • <aside class="example"> can contain nested <pre> elements with mixed prose and code
โš ๏ธ **GitHub.com Fallback** โš ๏ธ