Skip to content

Commit aa3746d

Browse files
committed
doc: implement fancier rendering for keys
Minimal CSS and markup changes to implement special rendering for `<kbd>` elements. PR-URL: #35400 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
1 parent 9e0bc33 commit aa3746d

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

doc/api/repl.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ feature set.
3535
The following special commands are supported by all REPL instances:
3636

3737
* `.break`: When in the process of inputting a multi-line expression, enter
38-
the `.break` command (or press **Ctrl+C**) to abort
38+
the `.break` command (or press <kbd>Ctrl</kbd>+<kbd>C</kbd>) to abort
3939
further input or processing of that expression.
4040
* `.clear`: Resets the REPL `context` to an empty object and clears any
4141
multi-line expression being input.
@@ -45,7 +45,8 @@ The following special commands are supported by all REPL instances:
4545
`> .save ./file/to/save.js`
4646
* `.load`: Load a file into the current REPL session.
4747
`> .load ./file/to/load.js`
48-
* `.editor`: Enter editor mode (**Ctrl+D** to finish, **Ctrl+C** to cancel).
48+
* `.editor`: Enter editor mode (<kbd>Ctrl</kbd>+<kbd>D</kbd> to finish,
49+
<kbd>Ctrl</kbd>+<kbd>C</kbd> to cancel).
4950

5051
```console
5152
> .editor
@@ -63,11 +64,12 @@ welcome('Node.js User');
6364

6465
The following key combinations in the REPL have these special effects:
6566

66-
* **Ctrl+C**: When pressed once, has the same effect as the `.break` command.
67+
* <kbd>Ctrl</kbd>+<kbd>C</kbd>: When pressed once, has the same effect as the
68+
`.break` command.
6769
When pressed twice on a blank line, has the same effect as the `.exit`
6870
command.
69-
* **Ctrl+D**: Has the same effect as the `.exit` command.
70-
* `<tab>`: When pressed on a blank line, displays global and local (scope)
71+
* <kbd>Ctrl</kbd>+<kbd>D</kbd>: Has the same effect as the `.exit` command.
72+
* <kbd>Tab</kbd>: When pressed on a blank line, displays global and local (scope)
7173
variables. When pressed while entering other input, displays relevant
7274
autocompletion options.
7375

@@ -248,14 +250,15 @@ added:
248250
-->
249251

250252
The REPL supports bi-directional reverse-i-search similar to [ZSH][]. It is
251-
triggered with **Ctrl+R** to search backward and **Ctrl+S** to search
253+
triggered with <kbd>Ctrl</kbd>+<kbd>R</kbd> to search backward and
254+
<kbd>Ctrl</kbd>+<kbd>S</kbd> to search
252255
forwards.
253256

254257
Duplicated history entires will be skipped.
255258

256259
Entries are accepted as soon as any button is pressed that doesn't correspond
257-
with the reverse search. Cancelling is possible by pressing **Esc** or
258-
**Ctrl+C**.
260+
with the reverse search. Cancelling is possible by pressing <kbd>Esc</kbd> or
261+
<kbd>Ctrl</kbd>+<kbd>C</kbd>.
259262

260263
Changing the direction immediately searches for the next entry in the expected
261264
direction from the current position on.
@@ -381,8 +384,10 @@ added: v0.7.7
381384
-->
382385

383386
The `'exit'` event is emitted when the REPL is exited either by receiving the
384-
`.exit` command as input, the user pressing **Ctrl+C** twice to signal `SIGINT`,
385-
or by pressing **Ctrl+D** to signal `'end'` on the input stream. The listener
387+
`.exit` command as input, the user pressing <kbd>Ctrl</kbd>+<kbd>C</kbd> twice
388+
to signal `SIGINT`,
389+
or by pressing <kbd>Ctrl</kbd>+<kbd>D</kbd> to signal `'end'` on the input
390+
stream. The listener
386391
callback is invoked without any arguments.
387392

388393
```js
@@ -615,7 +620,8 @@ changes:
615620
* `repl.REPL_MODE_STRICT` to evaluate expressions in strict mode. This is
616621
equivalent to prefacing every repl statement with `'use strict'`.
617622
* `breakEvalOnSigint` {boolean} Stop evaluating the current piece of code when
618-
`SIGINT` is received, such as when `Ctrl+C` is pressed. This cannot be used
623+
`SIGINT` is received, such as when <kbd>Ctrl</kbd>+<kbd>C</kbd> is pressed.
624+
This cannot be used
619625
together with a custom `eval` function. **Default:** `false`.
620626
* `preview` {boolean} Defines if the repl prints autocomplete and output
621627
previews or not. **Default:** `true` with the default eval function and

doc/api_assets/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ td > *:last-child {
572572
margin-bottom: 0;
573573
}
574574

575+
kbd {
576+
font-size: 1.2em;
577+
font-weight: 700;
578+
border-radius: 3px;
579+
padding: 1px 2px 0;
580+
border: 1px solid black;
581+
}
582+
575583
.changelog > summary {
576584
margin: .5rem 0;
577585
padding: .5rem 0;

0 commit comments

Comments
 (0)