Browse Source

More compact examples

Bzero 1 year ago
parent
commit
024f2d3c0a

+ 67 - 142
book/src/list-functions-datetime.md

@@ -21,36 +21,21 @@ fn datetime(input: String) -> DateTime
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=datetime%28%222022%2D07%2D20T21%3A52%2B0200%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> datetime("2022-07-20T21:52+0200")
-    
-      datetime("2022-07-20T21:52+0200")
-    
-        = 2022-07-20 19:52:00 UTC    [DateTime]
-    
-  ```
-* <a href="https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20Europe%2FBerlin%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> datetime("2022-07-20 21:52 Europe/Berlin")
-    
-      datetime("2022-07-20 21:52 Europe/Berlin")
-    
-        = 2022-07-20 21:52:00 CEST (UTC +02), Europe/Berlin    [DateTime]
-    
-  ```
-* <a href="https://numbat.dev/?q=datetime%28%222022%2F07%2F20%2009%3A52%20PM%20%2B0200%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> datetime("2022/07/20 09:52 PM +0200")
-    
-      datetime("2022/07/20 09:52 PM +0200")
-    
-        = 2022-07-20 21:52:00 (UTC +02)    [DateTime]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2D07%2D20T21%3A52%2B0200%22%29')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022-07-20T21:52+0200")
+
+    = 2022-07-20 19:52:00 UTC    [DateTime]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20Europe%2FBerlin%22%29')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022-07-20 21:52 Europe/Berlin")
+
+    = 2022-07-20 21:52:00 CEST (UTC +02), Europe/Berlin    [DateTime]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2F07%2F20%2009%3A52%20PM%20%2B0200%22%29')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022/07/20 09:52 PM +0200")
+
+    = 2022-07-20 21:52:00 (UTC +02)    [DateTime]
+</code></pre>
+
 </details>
 
 ### `format_datetime`
@@ -63,16 +48,11 @@ fn format_datetime(format: String, input: DateTime) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=format%5Fdatetime%28%22This%20is%20a%20date%20in%20%25B%20in%20the%20year%20%25Y%2E%22%2C%20datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=format%5Fdatetime%28%22This%20is%20a%20date%20in%20%25B%20in%20the%20year%20%25Y%2E%22%2C%20datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29')""></button></div><code class="language-nbt hljs numbat">>>> format_datetime("This is a date in %B in the year %Y.", datetime("2022-07-20 21:52 +0200"))
+
+    = "This is a date in July in the year 2022."    [String]
+</code></pre>
 
-  ```nbt
-    >>> format_datetime("This is a date in %B in the year %Y.", datetime("2022-07-20 21:52 +0200"))
-    
-      format_datetime("This is a date in %B in the year %Y.", datetime("2022-07-20 21:52 +0200"))
-    
-        = "This is a date in July in the year 2022."    [String]
-    
-  ```
 </details>
 
 ### `get_local_timezone`
@@ -85,16 +65,11 @@ fn get_local_timezone() -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=get%5Flocal%5Ftimezone%28%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=get%5Flocal%5Ftimezone%28%29')""></button></div><code class="language-nbt hljs numbat">>>> get_local_timezone()
+
+    = "UTC"    [String]
+</code></pre>
 
-  ```nbt
-    >>> get_local_timezone()
-    
-      get_local_timezone()
-    
-        = "UTC"    [String]
-    
-  ```
 </details>
 
 ### `tz`
@@ -107,26 +82,16 @@ fn tz(tz: String) -> Fn[(DateTime) -> DateTime]
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20tz%28%22Europe%2FAmsterdam%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> datetime("2022-07-20 21:52 +0200") -> tz("Europe/Amsterdam")
-    
-      tz("Europe/Amsterdam")(datetime("2022-07-20 21:52 +0200"))
-    
-        = 2022-07-20 21:52:00 CEST (UTC +02), Europe/Amsterdam    [DateTime]
-    
-  ```
-* <a href="https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20tz%28%22Asia%2FTaipei%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> datetime("2022-07-20 21:52 +0200") -> tz("Asia/Taipei")
-    
-      tz("Asia/Taipei")(datetime("2022-07-20 21:52 +0200"))
-    
-        = 2022-07-21 03:52:00 CST (UTC +08), Asia/Taipei    [DateTime]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20tz%28%22Europe%2FAmsterdam%22%29')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022-07-20 21:52 +0200") -> tz("Europe/Amsterdam")
+
+    = 2022-07-20 21:52:00 CEST (UTC +02), Europe/Amsterdam    [DateTime]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20tz%28%22Asia%2FTaipei%22%29')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022-07-20 21:52 +0200") -> tz("Asia/Taipei")
+
+    = 2022-07-21 03:52:00 CST (UTC +08), Asia/Taipei    [DateTime]
+</code></pre>
+
 </details>
 
 ### `unixtime`
@@ -139,16 +104,11 @@ fn unixtime(input: DateTime) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20unixtime"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%20%2D%3E%20unixtime')""></button></div><code class="language-nbt hljs numbat">>>> datetime("2022-07-20 21:52 +0200") -> unixtime
+
+    = 1_658_346_720
+</code></pre>
 
-  ```nbt
-    >>> datetime("2022-07-20 21:52 +0200") -> unixtime
-    
-      unixtime(datetime("2022-07-20 21:52 +0200"))
-    
-        = 1_658_346_720
-    
-  ```
 </details>
 
 ### `from_unixtime`
@@ -161,16 +121,11 @@ fn from_unixtime(input: Scalar) -> DateTime
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=from%5Funixtime%282%5E31%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=from%5Funixtime%282%5E31%29')""></button></div><code class="language-nbt hljs numbat">>>> from_unixtime(2^31)
+
+    = 2038-01-19 03:14:08 UTC    [DateTime]
+</code></pre>
 
-  ```nbt
-    >>> from_unixtime(2^31)
-    
-      from_unixtime(2^31)
-    
-        = 2038-01-19 03:14:08 UTC    [DateTime]
-    
-  ```
 </details>
 
 ### `today`
@@ -190,16 +145,11 @@ fn date(input: String) -> DateTime
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=date%28%222022%2D07%2D20%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=date%28%222022%2D07%2D20%22%29')""></button></div><code class="language-nbt hljs numbat">>>> date("2022-07-20")
+
+    = 2022-07-20 00:00:00 UTC    [DateTime]
+</code></pre>
 
-  ```nbt
-    >>> date("2022-07-20")
-    
-      date("2022-07-20")
-    
-        = 2022-07-20 00:00:00 UTC    [DateTime]
-    
-  ```
 </details>
 
 ### `time`
@@ -219,16 +169,11 @@ fn calendar_add(dt: DateTime, span: Time) -> DateTime
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=calendar%5Fadd%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%2C%202%20years%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=calendar%5Fadd%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%2C%202%20years%29')""></button></div><code class="language-nbt hljs numbat">>>> calendar_add(datetime("2022-07-20 21:52 +0200"), 2 years)
+
+    = 2024-07-20 21:52:00 (UTC +02)    [DateTime]
+</code></pre>
 
-  ```nbt
-    >>> calendar_add(datetime("2022-07-20 21:52 +0200"), 2 years)
-    
-      calendar_add(datetime("2022-07-20 21:52 +0200"), 2 year)
-    
-        = 2024-07-20 21:52:00 (UTC +02)    [DateTime]
-    
-  ```
 </details>
 
 ### `calendar_sub`
@@ -241,16 +186,11 @@ fn calendar_sub(dt: DateTime, span: Time) -> DateTime
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=calendar%5Fsub%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%2C%203%20years%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=calendar%5Fsub%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%2C%203%20years%29')""></button></div><code class="language-nbt hljs numbat">>>> calendar_sub(datetime("2022-07-20 21:52 +0200"), 3 years)
+
+    = 2019-07-20 21:52:00 (UTC +02)    [DateTime]
+</code></pre>
 
-  ```nbt
-    >>> calendar_sub(datetime("2022-07-20 21:52 +0200"), 3 years)
-    
-      calendar_sub(datetime("2022-07-20 21:52 +0200"), 3 year)
-    
-        = 2019-07-20 21:52:00 (UTC +02)    [DateTime]
-    
-  ```
 </details>
 
 ### `weekday`
@@ -263,16 +203,11 @@ fn weekday(dt: DateTime) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=weekday%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=weekday%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29')""></button></div><code class="language-nbt hljs numbat">>>> weekday(datetime("2022-07-20 21:52 +0200"))
+
+    = "Wednesday"    [String]
+</code></pre>
 
-  ```nbt
-    >>> weekday(datetime("2022-07-20 21:52 +0200"))
-    
-      weekday(datetime("2022-07-20 21:52 +0200"))
-    
-        = "Wednesday"    [String]
-    
-  ```
 </details>
 
 ### `julian_date` (Julian date)
@@ -286,16 +221,11 @@ fn julian_date(dt: DateTime) -> Time
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=julian%5Fdate%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=julian%5Fdate%28datetime%28%222022%2D07%2D20%2021%3A52%20%2B0200%22%29%29')""></button></div><code class="language-nbt hljs numbat">>>> julian_date(datetime("2022-07-20 21:52 +0200"))
+
+    = 2.45978e+6 day    [Time]
+</code></pre>
 
-  ```nbt
-    >>> julian_date(datetime("2022-07-20 21:52 +0200"))
-    
-      julian_date(datetime("2022-07-20 21:52 +0200"))
-    
-        = 2.45978e+6 day    [Time]
-    
-  ```
 </details>
 
 ### `human` (Human-readable time duration)
@@ -309,16 +239,11 @@ fn human(time: Time) -> String
 <details>
 <summary>Examples</summary>
 
-* How long is a microcentury?
-
-  <a href="https://numbat.dev/?q=century%2F1e6%20%2D%3E%20human"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> century/1e6 -> human
-    
-      human(century / 1_000_000)
-    
-        = "52 minutes + 35.692505184 seconds"    [String]
-    
-  ```
+How long is a microcentury?
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=century%2F1e6%20%2D%3E%20human')""></button></div><code class="language-nbt hljs numbat">>>> century/1e6 -> human
+
+    = "52 minutes + 35.692505184 seconds"    [String]
+</code></pre>
+
 </details>
 

+ 102 - 219
book/src/list-functions-lists.md

@@ -12,16 +12,11 @@ fn len<A>(xs: List<A>) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=len%28%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> len([3, 2, 1])
-    
-      len([3, 2, 1])
-    
-        = 3
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=len%28%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> len([3, 2, 1])
+
+    = 3
+</code></pre>
+
 </details>
 
 ### `head`
@@ -34,16 +29,11 @@ fn head<A>(xs: List<A>) -> A
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=head%28%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=head%28%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> head([3, 2, 1])
+
+    = 3
+</code></pre>
 
-  ```nbt
-    >>> head([3, 2, 1])
-    
-      head([3, 2, 1])
-    
-        = 3
-    
-  ```
 </details>
 
 ### `tail`
@@ -56,16 +46,11 @@ fn tail<A>(xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=tail%28%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=tail%28%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> tail([3, 2, 1])
+
+    = [2, 1]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> tail([3, 2, 1])
-    
-      tail([3, 2, 1])
-    
-        = [2, 1]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `cons`
@@ -78,16 +63,11 @@ fn cons<A>(x: A, xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=cons%2877%2C%20%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=cons%2877%2C%20%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> cons(77, [3, 2, 1])
+
+    = [77, 3, 2, 1]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> cons(77, [3, 2, 1])
-    
-      cons(77, [3, 2, 1])
-    
-        = [77, 3, 2, 1]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `cons_end`
@@ -100,16 +80,11 @@ fn cons_end<A>(x: A, xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=cons%5Fend%2877%2C%20%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=cons%5Fend%2877%2C%20%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> cons_end(77, [3, 2, 1])
+
+    = [3, 2, 1, 77]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> cons_end(77, [3, 2, 1])
-    
-      cons_end(77, [3, 2, 1])
-    
-        = [3, 2, 1, 77]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `is_empty`
@@ -122,26 +97,16 @@ fn is_empty<A>(xs: List<A>) -> Bool
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=is%5Fempty%28%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_empty([3, 2, 1])
-    
-      is_empty([3, 2, 1])
-    
-        = false    [Bool]
-    
-  ```
-* <a href="https://numbat.dev/?q=is%5Fempty%28%5B%5D%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_empty([])
-    
-      is_empty([])
-    
-        = true    [Bool]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Fempty%28%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> is_empty([3, 2, 1])
+
+    = false    [Bool]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Fempty%28%5B%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> is_empty([])
+
+    = true    [Bool]
+</code></pre>
+
 </details>
 
 ### `concat`
@@ -154,16 +119,11 @@ fn concat<A>(xs1: List<A>, xs2: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=concat%28%5B3%2C%202%2C%201%5D%2C%20%5B10%2C%2011%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=concat%28%5B3%2C%202%2C%201%5D%2C%20%5B10%2C%2011%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> concat([3, 2, 1], [10, 11])
+
+    = [3, 2, 1, 10, 11]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> concat([3, 2, 1], [10, 11])
-    
-      concat([3, 2, 1], [10, 11])
-    
-        = [3, 2, 1, 10, 11]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `take`
@@ -176,16 +136,11 @@ fn take<A>(n: Scalar, xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=take%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=take%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> take(2, [3, 2, 1, 0])
+
+    = [3, 2]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> take(2, [3, 2, 1, 0])
-    
-      take(2, [3, 2, 1, 0])
-    
-        = [3, 2]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `drop`
@@ -198,16 +153,11 @@ fn drop<A>(n: Scalar, xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=drop%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=drop%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> drop(2, [3, 2, 1, 0])
+
+    = [1, 0]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> drop(2, [3, 2, 1, 0])
-    
-      drop(2, [3, 2, 1, 0])
-    
-        = [1, 0]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `element_at`
@@ -220,16 +170,11 @@ fn element_at<A>(i: Scalar, xs: List<A>) -> A
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=element%5Fat%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=element%5Fat%282%2C%20%5B3%2C%202%2C%201%2C%200%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> element_at(2, [3, 2, 1, 0])
+
+    = 1
+</code></pre>
 
-  ```nbt
-    >>> element_at(2, [3, 2, 1, 0])
-    
-      element_at(2, [3, 2, 1, 0])
-    
-        = 1
-    
-  ```
 </details>
 
 ### `range`
@@ -242,16 +187,11 @@ fn range(start: Scalar, end: Scalar) -> List<Scalar>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=range%282%2C%2012%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=range%282%2C%2012%29')""></button></div><code class="language-nbt hljs numbat">>>> range(2, 12)
+
+    = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> range(2, 12)
-    
-      range(2, 12)
-    
-        = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `reverse`
@@ -264,16 +204,11 @@ fn reverse<A>(xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=reverse%28%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=reverse%28%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> reverse([3, 2, 1])
+
+    = [1, 2, 3]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> reverse([3, 2, 1])
-    
-      reverse([3, 2, 1])
-    
-        = [1, 2, 3]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `map`
@@ -286,17 +221,12 @@ fn map<A, B>(f: Fn[(A) -> B], xs: List<A>) -> List<B>
 <details>
 <summary>Examples</summary>
 
-* Square all elements of a list.
-
-  <a href="https://numbat.dev/?q=map%28sqr%2C%20%5B3%2C%202%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> map(sqr, [3, 2, 1])
-    
-      map(sqr, [3, 2, 1])
-    
-        = [9, 4, 1]    [List<Scalar>]
-    
-  ```
+Square all elements of a list.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=map%28sqr%2C%20%5B3%2C%202%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> map(sqr, [3, 2, 1])
+
+    = [9, 4, 1]    [List<Scalar>]
+</code></pre>
+
 </details>
 
 ### `filter`
@@ -309,16 +239,11 @@ fn filter<A>(p: Fn[(A) -> Bool], xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=filter%28is%5Ffinite%2C%20%5B0%2C%201e10%2C%20NaN%2C%20%2Dinf%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=filter%28is%5Ffinite%2C%20%5B0%2C%201e10%2C%20NaN%2C%20%2Dinf%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> filter(is_finite, [0, 1e10, NaN, -inf])
+
+    = [0, 10_000_000_000]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> filter(is_finite, [0, 1e10, NaN, -inf])
-    
-      filter(is_finite, [0, 10_000_000_000, NaN, -inf])
-    
-        = [0, 10_000_000_000]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `foldl`
@@ -331,17 +256,12 @@ fn foldl<A, B>(f: Fn[(A, B) -> A], acc: A, xs: List<B>) -> A
 <details>
 <summary>Examples</summary>
 
-* Join a list of strings by folding.
-
-  <a href="https://numbat.dev/?q=foldl%28str%5Fappend%2C%20%22%22%2C%20%5B%22Num%22%2C%20%22bat%22%2C%20%22%21%22%5D%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> foldl(str_append, "", ["Num", "bat", "!"])
-    
-      foldl(str_append, "", ["Num", "bat", "!"])
-    
-        = "Numbat!"    [String]
-    
-  ```
+Join a list of strings by folding.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=foldl%28str%5Fappend%2C%20%22%22%2C%20%5B%22Num%22%2C%20%22bat%22%2C%20%22%21%22%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> foldl(str_append, "", ["Num", "bat", "!"])
+
+    = "Numbat!"    [String]
+</code></pre>
+
 </details>
 
 ### `sort_by_key`
@@ -354,20 +274,13 @@ fn sort_by_key<A, D: Dim>(key: Fn[(A) -> D], xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* Sort by last digit.
-
-  <a href="https://numbat.dev/?q=fn%20last%5Fdigit%28x%29%20%3D%20mod%28x%2C%2010%29%0Asort%5Fby%5Fkey%28last%5Fdigit%2C%20%5B701%2C%20313%2C%209999%2C%204%5D%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn last_digit(x) = mod(x, 10)
-    sort_by_key(last_digit, [701, 313, 9999, 4])
-    
-      fn last_digit(x: Scalar) -> Scalar = mod(x, 10)
-    
-      sort_by_key(last_digit, [701, 313, 9999, 4])
-    
-        = [701, 313, 4, 9999]    [List<Scalar>]
-    
-  ```
+Sort by last digit.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=fn%20last%5Fdigit%28x%29%20%3D%20mod%28x%2C%2010%29%0Asort%5Fby%5Fkey%28last%5Fdigit%2C%20%5B701%2C%20313%2C%209999%2C%204%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> fn last_digit(x) = mod(x, 10)
+sort_by_key(last_digit, [701, 313, 9999, 4])
+
+    = [701, 313, 4, 9999]    [List<Scalar>]
+</code></pre>
+
 </details>
 
 ### `sort`
@@ -380,16 +293,11 @@ fn sort<D: Dim>(xs: List<D>) -> List<D>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=sort%28%5B3%2C%202%2C%207%2C%208%2C%20%2D4%2C%200%2C%20%2D5%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=sort%28%5B3%2C%202%2C%207%2C%208%2C%20%2D4%2C%200%2C%20%2D5%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> sort([3, 2, 7, 8, -4, 0, -5])
+
+    = [-5, -4, 0, 2, 3, 7, 8]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> sort([3, 2, 7, 8, -4, 0, -5])
-    
-      sort([3, 2, 7, 8, -4, 0, -5])
-    
-        = [-5, -4, 0, 2, 3, 7, 8]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `intersperse`
@@ -402,16 +310,11 @@ fn intersperse<A>(sep: A, xs: List<A>) -> List<A>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=intersperse%280%2C%20%5B1%2C%201%2C%201%2C%201%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=intersperse%280%2C%20%5B1%2C%201%2C%201%2C%201%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> intersperse(0, [1, 1, 1, 1])
+
+    = [1, 0, 1, 0, 1, 0, 1]    [List<Scalar>]
+</code></pre>
 
-  ```nbt
-    >>> intersperse(0, [1, 1, 1, 1])
-    
-      intersperse(0, [1, 1, 1, 1])
-    
-        = [1, 0, 1, 0, 1, 0, 1]    [List<Scalar>]
-    
-  ```
 </details>
 
 ### `sum`
@@ -424,16 +327,11 @@ fn sum<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=sum%28%5B3%20m%2C%20200%20cm%2C%201000%20mm%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=sum%28%5B3%20m%2C%20200%20cm%2C%201000%20mm%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> sum([3 m, 200 cm, 1000 mm])
+
+    = 6 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> sum([3 m, 200 cm, 1000 mm])
-    
-      sum([3 metre, 200 centimetre, 1000 millimetre])
-    
-        = 6 m    [Length]
-    
-  ```
 </details>
 
 ### `linspace`
@@ -446,16 +344,11 @@ fn linspace<D: Dim>(start: D, end: D, n_steps: Scalar) -> List<D>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=linspace%28%2D5%20m%2C%205%20m%2C%2011%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=linspace%28%2D5%20m%2C%205%20m%2C%2011%29')""></button></div><code class="language-nbt hljs numbat">>>> linspace(-5 m, 5 m, 11)
+
+    = [-5 m, -4 m, -3 m, -2 m, -1 m, 0 m, 1 m, 2 m, 3 m, 4 m, 5 m]    [List<Length>]
+</code></pre>
 
-  ```nbt
-    >>> linspace(-5 m, 5 m, 11)
-    
-      linspace(-(5 metre), 5 metre, 11)
-    
-        = [-5 m, -4 m, -3 m, -2 m, -1 m, 0 m, 1 m, 2 m, 3 m, 4 m, 5 m]    [List<Length>]
-    
-  ```
 </details>
 
 ### `join`
@@ -468,16 +361,11 @@ fn join(xs: List<String>, sep: String) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=join%28%5B%22snake%22%2C%20%22case%22%5D%2C%20%22%5F%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=join%28%5B%22snake%22%2C%20%22case%22%5D%2C%20%22%5F%22%29')""></button></div><code class="language-nbt hljs numbat">>>> join(["snake", "case"], "_")
+
+    = "snake_case"    [String]
+</code></pre>
 
-  ```nbt
-    >>> join(["snake", "case"], "_")
-    
-      join(["snake", "case"], "_")
-    
-        = "snake_case"    [String]
-    
-  ```
 </details>
 
 ### `split`
@@ -490,15 +378,10 @@ fn split(input: String, separator: String) -> List<String>
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=split%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22%20%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=split%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22%20%22%29')""></button></div><code class="language-nbt hljs numbat">>>> split("Numbat is a statically typed programming language.", " ")
+
+    = ["Numbat", "is", "a", "statically", "typed", "programming", "language."]    [List<String>]
+</code></pre>
 
-  ```nbt
-    >>> split("Numbat is a statically typed programming language.", " ")
-    
-      split("Numbat is a statically typed programming language.", " ")
-    
-        = ["Numbat", "is", "a", "statically", "typed", "programming", "language."]    [List<String>]
-    
-  ```
 </details>
 

+ 204 - 423
book/src/list-functions-math.md

@@ -16,16 +16,11 @@ fn id<A>(x: A) -> A
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=id%288%20kg%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> id(8 kg)
-    
-      id(8 kilogram)
-    
-        = 8 kg    [Mass]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=id%288%20kg%29')""></button></div><code class="language-nbt hljs numbat">>>> id(8 kg)
+
+    = 8 kg    [Mass]
+</code></pre>
+
 </details>
 
 ### `abs` (Absolute value)
@@ -39,16 +34,11 @@ fn abs<T: Dim>(x: T) -> T
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=abs%28%2D22%2E2%20m%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=abs%28%2D22%2E2%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> abs(-22.2 m)
+
+    = 22.2 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> abs(-22.2 m)
-    
-      abs(-(22.2 metre))
-    
-        = 22.2 m    [Length]
-    
-  ```
 </details>
 
 ### `sqrt` (Square root)
@@ -62,16 +52,11 @@ fn sqrt<D: Dim>(x: D^2) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=sqrt%284%20are%29%20%2D%3E%20m"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=sqrt%284%20are%29%20%2D%3E%20m')""></button></div><code class="language-nbt hljs numbat">>>> sqrt(4 are) -> m
+
+    = 20 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> sqrt(4 are) -> m
-    
-      sqrt(4 are) ➞ metre
-    
-        = 20 m    [Length]
-    
-  ```
 </details>
 
 ### `cbrt` (Cube root)
@@ -85,16 +70,11 @@ fn cbrt<D: Dim>(x: D^3) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=cbrt%288%20L%29%20%2D%3E%20cm"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=cbrt%288%20L%29%20%2D%3E%20cm')""></button></div><code class="language-nbt hljs numbat">>>> cbrt(8 L) -> cm
+
+    = 20.0 cm    [Length]
+</code></pre>
 
-  ```nbt
-    >>> cbrt(8 L) -> cm
-    
-      cbrt(8 litre) ➞ centimetre
-    
-        = 20.0 cm    [Length]
-    
-  ```
 </details>
 
 ### `sqr` (Square function)
@@ -107,16 +87,11 @@ fn sqr<D: Dim>(x: D) -> D^2
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=sqr%287%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=sqr%287%29')""></button></div><code class="language-nbt hljs numbat">>>> sqr(7)
+
+    = 49
+</code></pre>
 
-  ```nbt
-    >>> sqr(7)
-    
-      sqr(7)
-    
-        = 49
-    
-  ```
 </details>
 
 ### `round` (Rounding)
@@ -130,26 +105,16 @@ fn round(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=round%285%2E5%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> round(5.5)
-    
-      round(5.5)
-    
-        = 6
-    
-  ```
-* <a href="https://numbat.dev/?q=round%28%2D5%2E5%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> round(-5.5)
-    
-      round(-5.5)
-    
-        = -6
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=round%285%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> round(5.5)
+
+    = 6
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=round%28%2D5%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> round(-5.5)
+
+    = -6
+</code></pre>
+
 </details>
 
 ### `round_in` (Rounding)
@@ -162,28 +127,18 @@ fn round_in<D: Dim>(base: D, value: D) -> D
 <details>
 <summary>Examples</summary>
 
-* Round in meters.
-
-  <a href="https://numbat.dev/?q=round%5Fin%28m%2C%205%2E3%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> round_in(m, 5.3 m)
-    
-      round_in(metre, 5.3 metre)
-    
-        = 5 m    [Length]
-    
-  ```
-* Round in centimeters.
-
-  <a href="https://numbat.dev/?q=round%5Fin%28cm%2C%205%2E3%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> round_in(cm, 5.3 m)
-    
-      round_in(centimetre, 5.3 metre)
-    
-        = 530 cm    [Length]
-    
-  ```
+Round in meters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=round%5Fin%28m%2C%205%2E3%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> round_in(m, 5.3 m)
+
+    = 5 m    [Length]
+</code></pre>
+
+Round in centimeters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=round%5Fin%28cm%2C%205%2E3%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> round_in(cm, 5.3 m)
+
+    = 530 cm    [Length]
+</code></pre>
+
 </details>
 
 ### `floor` (Floor function)
@@ -197,16 +152,11 @@ fn floor(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=floor%285%2E5%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=floor%285%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> floor(5.5)
+
+    = 5
+</code></pre>
 
-  ```nbt
-    >>> floor(5.5)
-    
-      floor(5.5)
-    
-        = 5
-    
-  ```
 </details>
 
 ### `floor_in` (Floor function)
@@ -219,28 +169,18 @@ fn floor_in<D: Dim>(base: D, value: D) -> D
 <details>
 <summary>Examples</summary>
 
-* Floor in meters.
-
-  <a href="https://numbat.dev/?q=floor%5Fin%28m%2C%205%2E7%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> floor_in(m, 5.7 m)
-    
-      floor_in(metre, 5.7 metre)
-    
-        = 5 m    [Length]
-    
-  ```
-* Floor in centimeters.
-
-  <a href="https://numbat.dev/?q=floor%5Fin%28cm%2C%205%2E7%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> floor_in(cm, 5.7 m)
-    
-      floor_in(centimetre, 5.7 metre)
-    
-        = 570 cm    [Length]
-    
-  ```
+Floor in meters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=floor%5Fin%28m%2C%205%2E7%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> floor_in(m, 5.7 m)
+
+    = 5 m    [Length]
+</code></pre>
+
+Floor in centimeters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=floor%5Fin%28cm%2C%205%2E7%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> floor_in(cm, 5.7 m)
+
+    = 570 cm    [Length]
+</code></pre>
+
 </details>
 
 ### `ceil` (Ceil function)
@@ -254,16 +194,11 @@ fn ceil(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=ceil%285%2E5%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=ceil%285%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> ceil(5.5)
+
+    = 6
+</code></pre>
 
-  ```nbt
-    >>> ceil(5.5)
-    
-      ceil(5.5)
-    
-        = 6
-    
-  ```
 </details>
 
 ### `ceil_in` (Ceil function)
@@ -276,28 +211,18 @@ fn ceil_in<D: Dim>(base: D, value: D) -> D
 <details>
 <summary>Examples</summary>
 
-* Ceil in meters.
-
-  <a href="https://numbat.dev/?q=ceil%5Fin%28m%2C%205%2E3%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> ceil_in(m, 5.3 m)
-    
-      ceil_in(metre, 5.3 metre)
-    
-        = 6 m    [Length]
-    
-  ```
-* Ceil in centimeters.
-
-  <a href="https://numbat.dev/?q=ceil%5Fin%28cm%2C%205%2E3%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> ceil_in(cm, 5.3 m)
-    
-      ceil_in(centimetre, 5.3 metre)
-    
-        = 530 cm    [Length]
-    
-  ```
+Ceil in meters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=ceil%5Fin%28m%2C%205%2E3%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> ceil_in(m, 5.3 m)
+
+    = 6 m    [Length]
+</code></pre>
+
+Ceil in centimeters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=ceil%5Fin%28cm%2C%205%2E3%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> ceil_in(cm, 5.3 m)
+
+    = 530 cm    [Length]
+</code></pre>
+
 </details>
 
 ### `trunc` (Truncation)
@@ -311,26 +236,16 @@ fn trunc(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=trunc%285%2E5%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> trunc(5.5)
-    
-      trunc(5.5)
-    
-        = 5
-    
-  ```
-* <a href="https://numbat.dev/?q=trunc%28%2D5%2E5%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> trunc(-5.5)
-    
-      trunc(-5.5)
-    
-        = -5
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=trunc%285%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> trunc(5.5)
+
+    = 5
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=trunc%28%2D5%2E5%29')""></button></div><code class="language-nbt hljs numbat">>>> trunc(-5.5)
+
+    = -5
+</code></pre>
+
 </details>
 
 ### `trunc_in` (Truncation)
@@ -343,28 +258,18 @@ fn trunc_in<D: Dim>(base: D, value: D) -> D
 <details>
 <summary>Examples</summary>
 
-* Truncate in meters.
-
-  <a href="https://numbat.dev/?q=trunc%5Fin%28m%2C%205%2E7%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> trunc_in(m, 5.7 m)
-    
-      trunc_in(metre, 5.7 metre)
-    
-        = 5 m    [Length]
-    
-  ```
-* Truncate in centimeters.
-
-  <a href="https://numbat.dev/?q=trunc%5Fin%28cm%2C%205%2E7%20m%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> trunc_in(cm, 5.7 m)
-    
-      trunc_in(centimetre, 5.7 metre)
-    
-        = 570 cm    [Length]
-    
-  ```
+Truncate in meters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=trunc%5Fin%28m%2C%205%2E7%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> trunc_in(m, 5.7 m)
+
+    = 5 m    [Length]
+</code></pre>
+
+Truncate in centimeters.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=trunc%5Fin%28cm%2C%205%2E7%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> trunc_in(cm, 5.7 m)
+
+    = 570 cm    [Length]
+</code></pre>
+
 </details>
 
 ### `mod` (Modulo)
@@ -378,16 +283,11 @@ fn mod<T: Dim>(a: T, b: T) -> T
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=mod%2827%2C%205%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=mod%2827%2C%205%29')""></button></div><code class="language-nbt hljs numbat">>>> mod(27, 5)
+
+    = 2
+</code></pre>
 
-  ```nbt
-    >>> mod(27, 5)
-    
-      mod(27, 5)
-    
-        = 2
-    
-  ```
 </details>
 
 ## Transcendental functions
@@ -405,16 +305,11 @@ fn exp(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=exp%284%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=exp%284%29')""></button></div><code class="language-nbt hljs numbat">>>> exp(4)
+
+    = 54.5982
+</code></pre>
 
-  ```nbt
-    >>> exp(4)
-    
-      exp(4)
-    
-        = 54.5982
-    
-  ```
 </details>
 
 ### `ln` (Natural logarithm)
@@ -428,16 +323,11 @@ fn ln(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=ln%2820%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=ln%2820%29')""></button></div><code class="language-nbt hljs numbat">>>> ln(20)
+
+    = 2.99573
+</code></pre>
 
-  ```nbt
-    >>> ln(20)
-    
-      ln(20)
-    
-        = 2.99573
-    
-  ```
 </details>
 
 ### `log` (Natural logarithm)
@@ -451,16 +341,11 @@ fn log(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=log%2820%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=log%2820%29')""></button></div><code class="language-nbt hljs numbat">>>> log(20)
+
+    = 2.99573
+</code></pre>
 
-  ```nbt
-    >>> log(20)
-    
-      log(20)
-    
-        = 2.99573
-    
-  ```
 </details>
 
 ### `log10` (Common logarithm)
@@ -474,16 +359,11 @@ fn log10(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=log10%28100%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=log10%28100%29')""></button></div><code class="language-nbt hljs numbat">>>> log10(100)
+
+    = 2
+</code></pre>
 
-  ```nbt
-    >>> log10(100)
-    
-      log10(100)
-    
-        = 2
-    
-  ```
 </details>
 
 ### `log2` (Binary logarithm)
@@ -497,16 +377,11 @@ fn log2(x: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=log2%28256%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=log2%28256%29')""></button></div><code class="language-nbt hljs numbat">>>> log2(256)
+
+    = 8
+</code></pre>
 
-  ```nbt
-    >>> log2(256)
-    
-      log2(256)
-    
-        = 8
-    
-  ```
 </details>
 
 ### `gamma` (Gamma function)
@@ -626,16 +501,11 @@ fn maximum<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=maximum%28%5B30%20cm%2C%202%20m%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=maximum%28%5B30%20cm%2C%202%20m%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> maximum([30 cm, 2 m])
+
+    = 2 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> maximum([30 cm, 2 m])
-    
-      maximum([30 centimetre, 2 metre])
-    
-        = 2 m    [Length]
-    
-  ```
 </details>
 
 ### `minimum` (Minimum)
@@ -648,16 +518,11 @@ fn minimum<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=minimum%28%5B30%20cm%2C%202%20m%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=minimum%28%5B30%20cm%2C%202%20m%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> minimum([30 cm, 2 m])
+
+    = 30 cm    [Length]
+</code></pre>
 
-  ```nbt
-    >>> minimum([30 cm, 2 m])
-    
-      minimum([30 centimetre, 2 metre])
-    
-        = 30 cm    [Length]
-    
-  ```
 </details>
 
 ### `mean` (Arithmetic mean)
@@ -671,16 +536,11 @@ fn mean<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=mean%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=mean%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> mean([1 m, 2 m, 300 cm])
+
+    = 2 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> mean([1 m, 2 m, 300 cm])
-    
-      mean([1 metre, 2 metre, 300 centimetre])
-    
-        = 2 m    [Length]
-    
-  ```
 </details>
 
 ### `variance` (Variance)
@@ -694,16 +554,11 @@ fn variance<D: Dim>(xs: List<D>) -> D^2
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=variance%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=variance%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> variance([1 m, 2 m, 300 cm])
+
+    = 0.666667 m²    [Area]
+</code></pre>
 
-  ```nbt
-    >>> variance([1 m, 2 m, 300 cm])
-    
-      variance([1 metre, 2 metre, 300 centimetre])
-    
-        = 0.666667 m²    [Area]
-    
-  ```
 </details>
 
 ### `stdev` (Standard deviation)
@@ -717,16 +572,11 @@ fn stdev<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=stdev%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=stdev%28%5B1%20m%2C%202%20m%2C%20300%20cm%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> stdev([1 m, 2 m, 300 cm])
+
+    = 0.816497 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> stdev([1 m, 2 m, 300 cm])
-    
-      stdev([1 metre, 2 metre, 300 centimetre])
-    
-        = 0.816497 m    [Length]
-    
-  ```
 </details>
 
 ### `median` (Median)
@@ -740,16 +590,11 @@ fn median<D: Dim>(xs: List<D>) -> D
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=median%28%5B1%20m%2C%202%20m%2C%20400%20cm%5D%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=median%28%5B1%20m%2C%202%20m%2C%20400%20cm%5D%29')""></button></div><code class="language-nbt hljs numbat">>>> median([1 m, 2 m, 400 cm])
+
+    = 2 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> median([1 m, 2 m, 400 cm])
-    
-      median([1 metre, 2 metre, 400 centimetre])
-    
-        = 2 m    [Length]
-    
-  ```
 </details>
 
 ## Random sampling, distributions
@@ -859,16 +704,11 @@ fn gcd(a: Scalar, b: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=gcd%2860%2C%2042%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=gcd%2860%2C%2042%29')""></button></div><code class="language-nbt hljs numbat">>>> gcd(60, 42)
+
+    = 6
+</code></pre>
 
-  ```nbt
-    >>> gcd(60, 42)
-    
-      gcd(60, 42)
-    
-        = 6
-    
-  ```
 </details>
 
 ### `lcm` (Least common multiple)
@@ -882,16 +722,11 @@ fn lcm(a: Scalar, b: Scalar) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=lcm%2814%2C%204%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=lcm%2814%2C%204%29')""></button></div><code class="language-nbt hljs numbat">>>> lcm(14, 4)
+
+    = 28
+</code></pre>
 
-  ```nbt
-    >>> lcm(14, 4)
-    
-      lcm(14, 4)
-    
-        = 28
-    
-  ```
 </details>
 
 ## Numerical methods
@@ -909,37 +744,21 @@ fn diff<X: Dim, Y: Dim>(f: Fn[(X) -> Y], x: X) -> Y / X
 <details>
 <summary>Examples</summary>
 
-* Compute the derivative of \\( f(x) = x² -x -1 \\) at \\( x=1 \\).
-
-  <a href="https://numbat.dev/?q=use%20numerics%3A%3Adiff%0Afn%20polynomial%28x%29%20%3D%20x%C2%B2%20%2D%20x%20%2D%201%0Adiff%28polynomial%2C%201%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn polynomial(x) = x² - x - 1
-    diff(polynomial, 1)
-    
-      fn polynomial(x: Scalar) -> Scalar = (x² - x) - 1
-    
-      diff(polynomial, 1)
-    
-        = 1.0
-    
-  ```
-* Compute the free fall velocity after \\( t=2 s \\).
-
-  <a href="https://numbat.dev/?q=use%20numerics%3A%3Adiff%0Afn%20distance%28t%29%20%3D%200%2E5%20g0%20t%C2%B2%0Afn%20velocity%28t%29%20%3D%20diff%28distance%2C%20t%29%0Avelocity%282%20s%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn distance(t) = 0.5 g0 t²
-    fn velocity(t) = diff(distance, t)
-    velocity(2 s)
-    
-      fn distance<A: Dim>(t: A) -> A² × Length / Time² = 0.5 g0 × t²
-    
-      fn velocity<A: Dim>(t: A) -> A × Length / Time² = diff(distance, t)
-    
-      velocity(2 second)
-    
-        = 19.6133 m/s    [Velocity]
-    
-  ```
+Compute the derivative of \\( f(x) = x² -x -1 \\) at \\( x=1 \\).
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20numerics%3A%3Adiff%0Afn%20polynomial%28x%29%20%3D%20x%C2%B2%20%2D%20x%20%2D%201%0Adiff%28polynomial%2C%201%29')""></button></div><code class="language-nbt hljs numbat">>>> fn polynomial(x) = x² - x - 1
+diff(polynomial, 1)
+
+    = 1.0
+</code></pre>
+
+Compute the free fall velocity after \\( t=2 s \\).
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20numerics%3A%3Adiff%0Afn%20distance%28t%29%20%3D%200%2E5%20g0%20t%C2%B2%0Afn%20velocity%28t%29%20%3D%20diff%28distance%2C%20t%29%0Avelocity%282%20s%29')""></button></div><code class="language-nbt hljs numbat">>>> fn distance(t) = 0.5 g0 t²
+fn velocity(t) = diff(distance, t)
+velocity(2 s)
+
+    = 19.6133 m/s    [Velocity]
+</code></pre>
+
 </details>
 
 ### `root_bisect` (Bisection method)
@@ -953,20 +772,13 @@ fn root_bisect<X: Dim, Y: Dim>(f: Fn[(X) -> Y], x1: X, x2: X, x_tol: X, y_tol: Y
 <details>
 <summary>Examples</summary>
 
-* Find the root of \\( f(x) = x² +x -2 \\) in the interval \\( [0, 100] \\).
-
-  <a href="https://numbat.dev/?q=use%20numerics%3A%3Asolve%0Afn%20f%28x%29%20%3D%20x%C2%B2%20%2Bx%20%2D2%0Aroot%5Fbisect%28f%2C%200%2C%20100%2C%200%2E01%2C%200%2E01%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn f(x) = x² +x -2
-    root_bisect(f, 0, 100, 0.01, 0.01)
-    
-      fn f(x: Scalar) -> Scalar = (x² + x) - 2
-    
-      root_bisect(f, 0, 100, 0.01, 0.01)
-    
-        = 1.00098
-    
-  ```
+Find the root of \\( f(x) = x² +x -2 \\) in the interval \\( [0, 100] \\).
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20numerics%3A%3Asolve%0Afn%20f%28x%29%20%3D%20x%C2%B2%20%2Bx%20%2D2%0Aroot%5Fbisect%28f%2C%200%2C%20100%2C%200%2E01%2C%200%2E01%29')""></button></div><code class="language-nbt hljs numbat">>>> fn f(x) = x² +x -2
+root_bisect(f, 0, 100, 0.01, 0.01)
+
+    = 1.00098
+</code></pre>
+
 </details>
 
 ### `root_newton` (Newton's method)
@@ -980,23 +792,14 @@ fn root_newton<X: Dim, Y: Dim>(f: Fn[(X) -> Y], f_prime: Fn[(X) -> Y / X], x0: X
 <details>
 <summary>Examples</summary>
 
-* Find a root of \\( f(x) = x² -3x +2 \\) using Newton's method.
-
-  <a href="https://numbat.dev/?q=use%20numerics%3A%3Asolve%0Afn%20f%28x%29%20%3D%20x%C2%B2%20%2D3x%20%2B2%0Afn%20f%5Fprime%28x%29%20%3D%202x%20%2D3%0Aroot%5Fnewton%28f%2C%20f%5Fprime%2C%200%20%2C%200%2E01%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn f(x) = x² -3x +2
-    fn f_prime(x) = 2x -3
-    root_newton(f, f_prime, 0 , 0.01)
-    
-      fn f(x: Scalar) -> Scalar = (x² - 3 x) + 2
-    
-      fn f_prime(x: Scalar) -> Scalar = 2 x - 3
-    
-      root_newton(f, f_prime, 0, 0.01)
-    
-        = 0.996078
-    
-  ```
+Find a root of \\( f(x) = x² -3x +2 \\) using Newton's method.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20numerics%3A%3Asolve%0Afn%20f%28x%29%20%3D%20x%C2%B2%20%2D3x%20%2B2%0Afn%20f%5Fprime%28x%29%20%3D%202x%20%2D3%0Aroot%5Fnewton%28f%2C%20f%5Fprime%2C%200%20%2C%200%2E01%29')""></button></div><code class="language-nbt hljs numbat">>>> fn f(x) = x² -3x +2
+fn f_prime(x) = 2x -3
+root_newton(f, f_prime, 0 , 0.01)
+
+    = 0.996078
+</code></pre>
+
 </details>
 
 ### `fixed_point` (Fixed-point iteration)
@@ -1010,20 +813,13 @@ fn fixed_point<X: Dim>(f: Fn[(X) -> X], x0: X, ε: X) -> X
 <details>
 <summary>Examples</summary>
 
-* Compute the fixed poin of \\( f(x) = x/2 -1 \\).
-
-  <a href="https://numbat.dev/?q=use%20numerics%3A%3Afixed%5Fpoint%0Afn%20function%28x%29%20%3D%20x%2F2%20%2D%201%0Afixed%5Fpoint%28function%2C%200%2C%200%2E01%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> fn function(x) = x/2 - 1
-    fixed_point(function, 0, 0.01)
-    
-      fn function(x: Scalar) -> Scalar = (x / 2) - 1
-    
-      fixed_point(function, 0, 0.01)
-    
-        = -1.99219
-    
-  ```
+Compute the fixed poin of \\( f(x) = x/2 -1 \\).
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20numerics%3A%3Afixed%5Fpoint%0Afn%20function%28x%29%20%3D%20x%2F2%20%2D%201%0Afixed%5Fpoint%28function%2C%200%2C%200%2E01%29')""></button></div><code class="language-nbt hljs numbat">>>> fn function(x) = x/2 - 1
+fixed_point(function, 0, 0.01)
+
+    = -1.99219
+</code></pre>
+
 </details>
 
 ## Geometry
@@ -1040,16 +836,11 @@ fn hypot2<T: Dim>(x: T, y: T) -> T
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=hypot2%283%20m%2C%204%20m%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=hypot2%283%20m%2C%204%20m%29')""></button></div><code class="language-nbt hljs numbat">>>> hypot2(3 m, 4 m)
+
+    = 5 m    [Length]
+</code></pre>
 
-  ```nbt
-    >>> hypot2(3 m, 4 m)
-    
-      hypot2(3 metre, 4 metre)
-    
-        = 5 m    [Length]
-    
-  ```
 </details>
 
 ### `hypot3`
@@ -1062,16 +853,11 @@ fn hypot3<T: Dim>(x: T, y: T, z: T) -> T
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=hypot3%288%2C%209%2C%2012%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=hypot3%288%2C%209%2C%2012%29')""></button></div><code class="language-nbt hljs numbat">>>> hypot3(8, 9, 12)
+
+    = 17
+</code></pre>
 
-  ```nbt
-    >>> hypot3(8, 9, 12)
-    
-      hypot3(8, 9, 12)
-    
-        = 17
-    
-  ```
 </details>
 
 ### `circle_area`
@@ -1117,17 +903,12 @@ fn quadratic_equation<A: Dim, B: Dim>(a: A, b: B, c: B^2 / A) -> List<B / A>
 <details>
 <summary>Examples</summary>
 
-* Solve the equation \\( 2x² -x -1 = 0 \\)
-
-  <a href="https://numbat.dev/?q=use%20extra%3A%3Aalgebra%0Aquadratic%5Fequation%282%2C%20%2D1%2C%20%2D1%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> quadratic_equation(2, -1, -1)
-    
-      quadratic_equation(2, -1, -1)
-    
-        = [1, -0.5]    [List<Scalar>]
-    
-  ```
+Solve the equation \\( 2x² -x -1 = 0 \\)
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Aalgebra%0Aquadratic%5Fequation%282%2C%20%2D1%2C%20%2D1%29')""></button></div><code class="language-nbt hljs numbat">>>> quadratic_equation(2, -1, -1)
+
+    = [1, -0.5]    [List<Scalar>]
+</code></pre>
+
 </details>
 
 ## Trigonometry (extra)

+ 110 - 225
book/src/list-functions-other.md

@@ -28,26 +28,16 @@ fn is_nan<T: Dim>(n: T) -> Bool
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=is%5Fnan%2837%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_nan(37)
-    
-      is_nan(37)
-    
-        = false    [Bool]
-    
-  ```
-* <a href="https://numbat.dev/?q=is%5Fnan%28NaN%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_nan(NaN)
-    
-      is_nan(NaN)
-    
-        = true    [Bool]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Fnan%2837%29')""></button></div><code class="language-nbt hljs numbat">>>> is_nan(37)
+
+    = false    [Bool]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Fnan%28NaN%29')""></button></div><code class="language-nbt hljs numbat">>>> is_nan(NaN)
+
+    = true    [Bool]
+</code></pre>
+
 </details>
 
 ### `is_infinite`
@@ -61,26 +51,16 @@ fn is_infinite<T: Dim>(n: T) -> Bool
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=is%5Finfinite%2837%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_infinite(37)
-    
-      is_infinite(37)
-    
-        = false    [Bool]
-    
-  ```
-* <a href="https://numbat.dev/?q=is%5Finfinite%28%2Dinf%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_infinite(-inf)
-    
-      is_infinite(-inf)
-    
-        = true    [Bool]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Finfinite%2837%29')""></button></div><code class="language-nbt hljs numbat">>>> is_infinite(37)
+
+    = false    [Bool]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Finfinite%28%2Dinf%29')""></button></div><code class="language-nbt hljs numbat">>>> is_infinite(-inf)
+
+    = true    [Bool]
+</code></pre>
+
 </details>
 
 ### `is_finite`
@@ -93,26 +73,16 @@ fn is_finite<T: Dim>(n: T) -> Bool
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=is%5Ffinite%2837%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_finite(37)
-    
-      is_finite(37)
-    
-        = true    [Bool]
-    
-  ```
-* <a href="https://numbat.dev/?q=is%5Ffinite%28%2Dinf%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> is_finite(-inf)
-    
-      is_finite(-inf)
-    
-        = false    [Bool]
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Ffinite%2837%29')""></button></div><code class="language-nbt hljs numbat">>>> is_finite(37)
+
+    = true    [Bool]
+</code></pre>
+
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=is%5Ffinite%28%2Dinf%29')""></button></div><code class="language-nbt hljs numbat">>>> is_finite(-inf)
+
+    = false    [Bool]
+</code></pre>
+
 </details>
 
 ## Quantities
@@ -129,16 +99,11 @@ fn unit_of<T: Dim>(x: T) -> T
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=unit%5Fof%2820%20km%2Fh%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=unit%5Fof%2820%20km%2Fh%29')""></button></div><code class="language-nbt hljs numbat">>>> unit_of(20 km/h)
+
+    = 1 km/h    [Velocity]
+</code></pre>
 
-  ```nbt
-    >>> unit_of(20 km/h)
-    
-      unit_of(20 kilometre / hour)
-    
-        = 1 km/h    [Velocity]
-    
-  ```
 </details>
 
 ### `value_of`
@@ -151,16 +116,11 @@ fn value_of<T: Dim>(x: T) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=value%5Fof%2820%20km%2Fh%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=value%5Fof%2820%20km%2Fh%29')""></button></div><code class="language-nbt hljs numbat">>>> value_of(20 km/h)
+
+    = 20
+</code></pre>
 
-  ```nbt
-    >>> value_of(20 km/h)
-    
-      value_of(20 kilometre / hour)
-    
-        = 20
-    
-  ```
 </details>
 
 ## Chemical elements
@@ -177,28 +137,18 @@ fn element(pattern: String) -> ChemicalElement
 <details>
 <summary>Examples</summary>
 
-* Get the entire element struct for hydrogen.
-
-  <a href="https://numbat.dev/?q=element%28%22H%22%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> element("H")
-    
-      element("H")
-    
-        = ChemicalElement { symbol: "H", name: "Hydrogen", atomic_number: 1, group: 1, group_name: "Alkali metals", period: 1, melting_point: 13.99 K, boiling_point: 20.271 K, density: 0.00008988 g/cm³, electron_affinity: 0.754 eV, ionization_energy: 13.598 eV, vaporization_heat: 0.904 kJ/mol }    [ChemicalElement]
-    
-  ```
-* Get the ionization energy of hydrogen.
-
-  <a href="https://numbat.dev/?q=element%28%22hydrogen%22%29%2Eionization%5Fenergy"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> element("hydrogen").ionization_energy
-    
-      element("hydrogen").ionization_energy
-    
-        = 13.598 eV    [Energy or Torque]
-    
-  ```
+Get the entire element struct for hydrogen.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=element%28%22H%22%29')""></button></div><code class="language-nbt hljs numbat">>>> element("H")
+
+    = ChemicalElement { symbol: "H", name: "Hydrogen", atomic_number: 1, group: 1, group_name: "Alkali metals", period: 1, melting_point: 13.99 K, boiling_point: 20.271 K, density: 0.00008988 g/cm³, electron_affinity: 0.754 eV, ionization_energy: 13.598 eV, vaporization_heat: 0.904 kJ/mol }    [ChemicalElement]
+</code></pre>
+
+Get the ionization energy of hydrogen.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=element%28%22hydrogen%22%29%2Eionization%5Fenergy')""></button></div><code class="language-nbt hljs numbat">>>> element("hydrogen").ionization_energy
+
+    = 13.598 eV    [Energy or Torque]
+</code></pre>
+
 </details>
 
 ## Mixed unit conversion
@@ -216,16 +166,11 @@ fn DMS(alpha: Angle) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=46%2E5858%C2%B0%20%2D%3E%20DMS"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=46%2E5858%C2%B0%20%2D%3E%20DMS')""></button></div><code class="language-nbt hljs numbat">>>> 46.5858° -> DMS
+
+    = "46° 35′ 9″"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 46.5858° -> DMS
-    
-      DMS(46.5858 degree)
-    
-        = "46° 35′ 9″"    [String]
-    
-  ```
 </details>
 
 ### `DM` (Degrees, decimal minutes)
@@ -239,16 +184,11 @@ fn DM(alpha: Angle) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=46%2E5858%C2%B0%20%2D%3E%20DM"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=46%2E5858%C2%B0%20%2D%3E%20DM')""></button></div><code class="language-nbt hljs numbat">>>> 46.5858° -> DM
+
+    = "46° 35.148′"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 46.5858° -> DM
-    
-      DM(46.5858 degree)
-    
-        = "46° 35.148′"    [String]
-    
-  ```
 </details>
 
 ### `feet_and_inches` (Feet and inches)
@@ -262,16 +202,11 @@ fn feet_and_inches(length: Length) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=180%20cm%20%2D%3E%20feet%5Fand%5Finches"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=180%20cm%20%2D%3E%20feet%5Fand%5Finches')""></button></div><code class="language-nbt hljs numbat">>>> 180 cm -> feet_and_inches
+
+    = "5 ft 10.8661 in"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 180 cm -> feet_and_inches
-    
-      feet_and_inches(180 centimetre)
-    
-        = "5 ft 10.8661 in"    [String]
-    
-  ```
 </details>
 
 ### `pounds_and_ounces` (Pounds and ounces)
@@ -285,16 +220,11 @@ fn pounds_and_ounces(mass: Mass) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=1%20kg%20%2D%3E%20pounds%5Fand%5Founces"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=1%20kg%20%2D%3E%20pounds%5Fand%5Founces')""></button></div><code class="language-nbt hljs numbat">>>> 1 kg -> pounds_and_ounces
+
+    = "2 lb 3.27396 oz"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 1 kg -> pounds_and_ounces
-    
-      pounds_and_ounces(1 kilogram)
-    
-        = "2 lb 3.27396 oz"    [String]
-    
-  ```
 </details>
 
 ## Temperature conversion
@@ -312,17 +242,12 @@ fn from_celsius(t_celsius: Scalar) -> Temperature
 <details>
 <summary>Examples</summary>
 
-* 300 °C in Kelvin.
-
-  <a href="https://numbat.dev/?q=from%5Fcelsius%28300%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> from_celsius(300)
-    
-      from_celsius(300)
-    
-        = 573.15 K    [Temperature]
-    
-  ```
+300 °C in Kelvin.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=from%5Fcelsius%28300%29')""></button></div><code class="language-nbt hljs numbat">>>> from_celsius(300)
+
+    = 573.15 K    [Temperature]
+</code></pre>
+
 </details>
 
 ### `celsius`
@@ -336,17 +261,12 @@ fn celsius(t_kelvin: Temperature) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* 300 K in degree Celsius.
-
-  <a href="https://numbat.dev/?q=300K%20%2D%3E%20celsius"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> 300K -> celsius
-    
-      celsius(300 kelvin)
-    
-        = 26.85
-    
-  ```
+300 K in degree Celsius.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=300K%20%2D%3E%20celsius')""></button></div><code class="language-nbt hljs numbat">>>> 300K -> celsius
+
+    = 26.85
+</code></pre>
+
 </details>
 
 ### `from_fahrenheit`
@@ -360,17 +280,12 @@ fn from_fahrenheit(t_fahrenheit: Scalar) -> Temperature
 <details>
 <summary>Examples</summary>
 
-* 300 °F in Kelvin.
-
-  <a href="https://numbat.dev/?q=from%5Ffahrenheit%28300%29"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> from_fahrenheit(300)
-    
-      from_fahrenheit(300)
-    
-        = 422.039 K    [Temperature]
-    
-  ```
+300 °F in Kelvin.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=from%5Ffahrenheit%28300%29')""></button></div><code class="language-nbt hljs numbat">>>> from_fahrenheit(300)
+
+    = 422.039 K    [Temperature]
+</code></pre>
+
 </details>
 
 ### `fahrenheit`
@@ -384,17 +299,12 @@ fn fahrenheit(t_kelvin: Temperature) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* 300 K in degree Fahrenheit.
-
-  <a href="https://numbat.dev/?q=300K%20%2D%3E%20fahrenheit"><i class="fa fa-play"></i> Run this example</a>
-  ```nbt
-    >>> 300K -> fahrenheit
-    
-      fahrenheit(300 kelvin)
-    
-        = 80.33
-    
-  ```
+300 K in degree Fahrenheit.
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=300K%20%2D%3E%20fahrenheit')""></button></div><code class="language-nbt hljs numbat">>>> 300K -> fahrenheit
+
+    = 80.33
+</code></pre>
+
 </details>
 
 ## Color format conversion
@@ -411,16 +321,11 @@ fn rgb(red: Scalar, green: Scalar, blue: Scalar) -> Color
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=use%20extra%3A%3Acolor%0Argb%28125%2C%20128%2C%20218%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Acolor%0Argb%28125%2C%20128%2C%20218%29')""></button></div><code class="language-nbt hljs numbat">>>> rgb(125, 128, 218)
+
+    = Color { red: 125, green: 128, blue: 218 }    [Color]
+</code></pre>
 
-  ```nbt
-    >>> rgb(125, 128, 218)
-    
-      rgb(125, 128, 218)
-    
-        = Color { red: 125, green: 128, blue: 218 }    [Color]
-    
-  ```
 </details>
 
 ### `color`
@@ -433,16 +338,11 @@ fn color(rgb_hex: Scalar) -> Color
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acolor%280xff7700%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acolor%280xff7700%29')""></button></div><code class="language-nbt hljs numbat">>>> color(0xff7700)
+
+    = Color { red: 255, green: 119, blue: 0 }    [Color]
+</code></pre>
 
-  ```nbt
-    >>> color(0xff7700)
-    
-      color(16_742_144)
-    
-        = Color { red: 255, green: 119, blue: 0 }    [Color]
-    
-  ```
 </details>
 
 ### `color_rgb`
@@ -455,16 +355,11 @@ fn color_rgb(color: Color) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acyan%20%2D%3E%20color%5Frgb"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acyan%20%2D%3E%20color%5Frgb')""></button></div><code class="language-nbt hljs numbat">>>> cyan -> color_rgb
+
+    = "rgb(0, 255, 255)"    [String]
+</code></pre>
 
-  ```nbt
-    >>> cyan -> color_rgb
-    
-      color_rgb(cyan)
-    
-        = "rgb(0, 255, 255)"    [String]
-    
-  ```
 </details>
 
 ### `color_rgb_float`
@@ -477,16 +372,11 @@ fn color_rgb_float(color: Color) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acyan%20%2D%3E%20color%5Frgb%5Ffloat"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Acolor%0Acyan%20%2D%3E%20color%5Frgb%5Ffloat')""></button></div><code class="language-nbt hljs numbat">>>> cyan -> color_rgb_float
+
+    = "rgb(0.000, 1.000, 1.000)"    [String]
+</code></pre>
 
-  ```nbt
-    >>> cyan -> color_rgb_float
-    
-      color_rgb_float(cyan)
-    
-        = "rgb(0.000, 1.000, 1.000)"    [String]
-    
-  ```
 </details>
 
 ### `color_hex`
@@ -499,15 +389,10 @@ fn color_hex(color: Color) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=use%20extra%3A%3Acolor%0Argb%28225%2C%2036%2C%20143%29%20%2D%3E%20color%5Fhex"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=use%20extra%3A%3Acolor%0Argb%28225%2C%2036%2C%20143%29%20%2D%3E%20color%5Fhex')""></button></div><code class="language-nbt hljs numbat">>>> rgb(225, 36, 143) -> color_hex
+
+    = "#e1248f"    [String]
+</code></pre>
 
-  ```nbt
-    >>> rgb(225, 36, 143) -> color_hex
-    
-      color_hex(rgb(225, 36, 143))
-    
-        = "#e1248f"    [String]
-    
-  ```
 </details>
 

+ 65 - 145
book/src/list-functions-strings.md

@@ -12,16 +12,11 @@ fn str_length(s: String) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Flength%28%22Numbat%22%29"><i class="fa fa-play"></i> Run this example</a>
-
-  ```nbt
-    >>> str_length("Numbat")
-    
-      str_length("Numbat")
-    
-        = 6
-    
-  ```
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Flength%28%22Numbat%22%29')""></button></div><code class="language-nbt hljs numbat">>>> str_length("Numbat")
+
+    = 6
+</code></pre>
+
 </details>
 
 ### `str_slice`
@@ -34,16 +29,11 @@ fn str_slice(s: String, start: Scalar, end: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Fslice%28%22Numbat%22%2C%203%2C%206%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Fslice%28%22Numbat%22%2C%203%2C%206%29')""></button></div><code class="language-nbt hljs numbat">>>> str_slice("Numbat", 3, 6)
+
+    = "bat"    [String]
+</code></pre>
 
-  ```nbt
-    >>> str_slice("Numbat", 3, 6)
-    
-      str_slice("Numbat", 3, 6)
-    
-        = "bat"    [String]
-    
-  ```
 </details>
 
 ### `chr`
@@ -56,16 +46,11 @@ fn chr(n: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=0x2764%20%2D%3E%20chr"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=0x2764%20%2D%3E%20chr')""></button></div><code class="language-nbt hljs numbat">>>> 0x2764 -> chr
+
+    = "❤"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 0x2764 -> chr
-    
-      chr(10084)
-    
-        = "❤"    [String]
-    
-  ```
 </details>
 
 ### `ord`
@@ -78,16 +63,11 @@ fn ord(s: String) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=%22%E2%9D%A4%22%20%2D%3E%20ord"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=%22%E2%9D%A4%22%20%2D%3E%20ord')""></button></div><code class="language-nbt hljs numbat">>>> "❤" -> ord
+
+    = 10084
+</code></pre>
 
-  ```nbt
-    >>> "❤" -> ord
-    
-      ord("❤")
-    
-        = 10084
-    
-  ```
 </details>
 
 ### `lowercase`
@@ -100,16 +80,11 @@ fn lowercase(s: String) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=lowercase%28%22Numbat%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=lowercase%28%22Numbat%22%29')""></button></div><code class="language-nbt hljs numbat">>>> lowercase("Numbat")
+
+    = "numbat"    [String]
+</code></pre>
 
-  ```nbt
-    >>> lowercase("Numbat")
-    
-      lowercase("Numbat")
-    
-        = "numbat"    [String]
-    
-  ```
 </details>
 
 ### `uppercase`
@@ -122,16 +97,11 @@ fn uppercase(s: String) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=uppercase%28%22Numbat%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=uppercase%28%22Numbat%22%29')""></button></div><code class="language-nbt hljs numbat">>>> uppercase("Numbat")
+
+    = "NUMBAT"    [String]
+</code></pre>
 
-  ```nbt
-    >>> uppercase("Numbat")
-    
-      uppercase("Numbat")
-    
-        = "NUMBAT"    [String]
-    
-  ```
 </details>
 
 ### `str_append`
@@ -144,16 +114,11 @@ fn str_append(a: String, b: String) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Fappend%28%22Numbat%22%2C%20%22%21%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Fappend%28%22Numbat%22%2C%20%22%21%22%29')""></button></div><code class="language-nbt hljs numbat">>>> str_append("Numbat", "!")
+
+    = "Numbat!"    [String]
+</code></pre>
 
-  ```nbt
-    >>> str_append("Numbat", "!")
-    
-      str_append("Numbat", "!")
-    
-        = "Numbat!"    [String]
-    
-  ```
 </details>
 
 ### `str_find`
@@ -166,16 +131,11 @@ fn str_find(haystack: String, needle: String) -> Scalar
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Ffind%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22typed%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Ffind%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22typed%22%29')""></button></div><code class="language-nbt hljs numbat">>>> str_find("Numbat is a statically typed programming language.", "typed")
+
+    = 23
+</code></pre>
 
-  ```nbt
-    >>> str_find("Numbat is a statically typed programming language.", "typed")
-    
-      str_find("Numbat is a statically typed programming language.", "typed")
-    
-        = 23
-    
-  ```
 </details>
 
 ### `str_contains`
@@ -188,16 +148,11 @@ fn str_contains(haystack: String, needle: String) -> Bool
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Fcontains%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22typed%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Fcontains%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22typed%22%29')""></button></div><code class="language-nbt hljs numbat">>>> str_contains("Numbat is a statically typed programming language.", "typed")
+
+    = true    [Bool]
+</code></pre>
 
-  ```nbt
-    >>> str_contains("Numbat is a statically typed programming language.", "typed")
-    
-      str_contains("Numbat is a statically typed programming language.", "typed")
-    
-        = true    [Bool]
-    
-  ```
 </details>
 
 ### `str_replace`
@@ -210,16 +165,11 @@ fn str_replace(s: String, pattern: String, replacement: String) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Freplace%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22statically%20typed%20programming%20language%22%2C%20%22scientific%20calculator%22%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Freplace%28%22Numbat%20is%20a%20statically%20typed%20programming%20language%2E%22%2C%20%22statically%20typed%20programming%20language%22%2C%20%22scientific%20calculator%22%29')""></button></div><code class="language-nbt hljs numbat">>>> str_replace("Numbat is a statically typed programming language.", "statically typed programming language", "scientific calculator")
+
+    = "Numbat is a scientific calculator."    [String]
+</code></pre>
 
-  ```nbt
-    >>> str_replace("Numbat is a statically typed programming language.", "statically typed programming language", "scientific calculator")
-    
-      str_replace("Numbat is a statically typed programming language.", "statically typed programming language", "scientific calculator")
-    
-        = "Numbat is a scientific calculator."    [String]
-    
-  ```
 </details>
 
 ### `str_repeat`
@@ -232,16 +182,11 @@ fn str_repeat(a: String, n: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=str%5Frepeat%28%22abc%22%2C%204%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=str%5Frepeat%28%22abc%22%2C%204%29')""></button></div><code class="language-nbt hljs numbat">>>> str_repeat("abc", 4)
+
+    = "abcabcabcabc"    [String]
+</code></pre>
 
-  ```nbt
-    >>> str_repeat("abc", 4)
-    
-      str_repeat("abc", 4)
-    
-        = "abcabcabcabc"    [String]
-    
-  ```
 </details>
 
 ### `base`
@@ -254,16 +199,11 @@ fn base(b: Scalar, x: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=42%20%7C%3E%20base%2816%29"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=42%20%7C%3E%20base%2816%29')""></button></div><code class="language-nbt hljs numbat">>>> 42 |> base(16)
+
+    = "2a"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 42 |> base(16)
-    
-      base(16, 42)
-    
-        = "2a"    [String]
-    
-  ```
 </details>
 
 ### `bin`
@@ -276,16 +216,11 @@ fn bin(x: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=42%20%2D%3E%20bin"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=42%20%2D%3E%20bin')""></button></div><code class="language-nbt hljs numbat">>>> 42 -> bin
+
+    = "0b101010"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 42 -> bin
-    
-      bin(42)
-    
-        = "0b101010"    [String]
-    
-  ```
 </details>
 
 ### `oct`
@@ -298,16 +233,11 @@ fn oct(x: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=42%20%2D%3E%20oct"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=42%20%2D%3E%20oct')""></button></div><code class="language-nbt hljs numbat">>>> 42 -> oct
+
+    = "0o52"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 42 -> oct
-    
-      oct(42)
-    
-        = "0o52"    [String]
-    
-  ```
 </details>
 
 ### `dec`
@@ -320,16 +250,11 @@ fn dec(x: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=0b111%20%2D%3E%20dec"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=0b111%20%2D%3E%20dec')""></button></div><code class="language-nbt hljs numbat">>>> 0b111 -> dec
+
+    = "7"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 0b111 -> dec
-    
-      dec(7)
-    
-        = "7"    [String]
-    
-  ```
 </details>
 
 ### `hex`
@@ -342,15 +267,10 @@ fn hex(x: Scalar) -> String
 <details>
 <summary>Examples</summary>
 
-* <a href="https://numbat.dev/?q=2%5E31%2D1%20%2D%3E%20hex"><i class="fa fa-play"></i> Run this example</a>
+<pre><div class="buttons"><button class="fa fa-play play-button" title="Run this code" aria-label="Run this code"  onclick=" window.open('https://numbat.dev/?q=2%5E31%2D1%20%2D%3E%20hex')""></button></div><code class="language-nbt hljs numbat">>>> 2^31-1 -> hex
+
+    = "0x7fffffff"    [String]
+</code></pre>
 
-  ```nbt
-    >>> 2^31-1 -> hex
-    
-      hex(2^31 - 1)
-    
-        = "0x7fffffff"    [String]
-    
-  ```
 </details>
 

+ 15 - 28
numbat/examples/inspect.rs

@@ -1,7 +1,6 @@
 use itertools::Itertools;
 use numbat::markup::plain_text_format;
 use numbat::module_importer::FileSystemImporter;
-use numbat::pretty_print::PrettyPrint;
 use numbat::resolver::CodeSource;
 use numbat::Context;
 use percent_encoding;
@@ -117,48 +116,36 @@ fn inspect_functions_in_module(ctx: &Context, prelude_ctx: &Context, module: Str
                     );
 
                     //Assemble the example output
-                    let mut example_output = String::new();
-                    example_output += "\n";
-
-                    for statement in &statements {
-                        example_output += &plain_text_format(&statement.pretty_print(), true);
-                        example_output += "\n\n";
-                    }
-
                     let result_markup = results.to_markup(
                         statements.last(),
                         &example_ctx.dimension_registry(),
                         true,
                         true,
                     );
-                    example_output += &plain_text_format(&result_markup, false);
-
-                    if results.is_value() {
-                        example_output += "\n";
-                    }
+                    let example_output = &plain_text_format(&result_markup, false);
 
                     //Print the example
                     if let Some(example_description) = example_description {
-                        println!(
-                        "* {}\n\n  <a href=\"{}\"><i class=\"fa fa-play\"></i> Run this example</a>",
-                        replace_equation_delimiters(example_description),
-                        example_url
-                    );
-                    } else {
-                        println!(
-                            "* <a href=\"{}\"><i class=\"fa fa-play\"></i> Run this example</a>\n",
-                            example_url
-                        );
+                        println!("{}", replace_equation_delimiters(example_description));
                     }
 
-                    println!("  ```nbt");
+                    print!("<pre>");
+                    print!("<div class=\"buttons\">");
+                    print!("<button class=\"fa fa-play play-button\" title=\"{}\" aria-label=\"{}\"  onclick=\" window.open('{}')\"\"></button>",
+                        "Run this code",
+                        "Run this code",
+                        example_url);
+                    print!("</div>");
+                    print!("<code class=\"language-nbt hljs numbat\">");
                     for l in example_input.lines() {
-                        println!("    {}", l);
+                        println!("{}", l);
                     }
+                    println!();
                     for l in example_output.lines() {
-                        println!("    {}", l);
+                        println!("{}", l);
                     }
-                    println!("  ```");
+                    println!("</code></pre>");
+                    println!();
                 } else {
                     eprintln!(
                         "Warning: Example \"{example_code}\" of function {fn_name} did not run successfully."