feat: simple-mode code-block highlighting, prompt, and copy rules
Add a custom Shiki grammar for the simple-mode command language (src/grammars/rdbms.mjs), registered with Expressive Code. Two language ids share it: rdbms (real commands) and rdbms-syntax (abstract templates). Simple-mode blocks now highlight; advanced examples keep sql. Separation + copy ergonomics via CSS (global.css): a decorative, copy-safe "> " prompt on rdbms command lines (not in the copy buffer), and the copy button hidden on multi-command rdbms blocks and on rdbms-syntax templates (the app input is single-line, so a multi-command paste is not runnable); single-command, sql, and sh blocks keep copy. Content: convert 22 simple-mode fences to rdbms; lead the simplest examples (first project, Tables reference) with bare "with pk" (the beginner default that creates a ready-made id key), pointing to the named form. Record the fence + prompt conventions in STYLE.md.
This commit is contained in:
@@ -15,41 +15,41 @@ and press <kbd>Enter</kbd> to run them.
|
||||
|
||||
## Create a table
|
||||
|
||||
A table needs at least a primary key. The `with pk` clause names the
|
||||
primary-key column and its type:
|
||||
The quickest way to make a table is `with pk` on its own, which gives you a
|
||||
ready-made primary key column called `id`:
|
||||
|
||||
```text
|
||||
create table authors with pk author_id(serial)
|
||||
```rdbms
|
||||
create table authors with pk
|
||||
```
|
||||
|
||||
`serial` is an auto-incrementing number — you will not have to fill it in
|
||||
yourself.
|
||||
You never fill `id` in yourself — the database assigns it as you add rows.
|
||||
(You can also name and type the key yourself; see the
|
||||
[Tables reference](/reference/tables/).)
|
||||
|
||||
## Add a couple of columns
|
||||
|
||||
In simple mode you create a table with its key, then add the other columns
|
||||
one at a time:
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
add column to authors: name (text)
|
||||
add column to authors: birth_year (int)
|
||||
```
|
||||
|
||||
## Add a row
|
||||
|
||||
`insert` adds a row. List the columns you are supplying — the `author_id`
|
||||
fills itself in because it is a `serial`:
|
||||
`insert` adds a row. List the columns you are supplying — `id` fills itself
|
||||
in automatically:
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
insert into authors (name, birth_year) values ('Ada Lovelace', 1815)
|
||||
```
|
||||
|
||||
The playground shows the row it just inserted, including the generated
|
||||
`author_id`.
|
||||
The playground shows the row it just inserted, including the generated `id`.
|
||||
|
||||
## Look at the data
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
show data authors
|
||||
```
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ in **simple mode**, and reach for **advanced mode** when you want full SQL.
|
||||
Simple mode is a friendly, keyword-based command language designed for
|
||||
learning. Commands read close to English:
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
create table authors with pk author_id(serial)
|
||||
show data authors
|
||||
```
|
||||
@@ -33,7 +33,7 @@ select title, published from books where published >= 2000 order by published;
|
||||
|
||||
Switch modes with the `mode` command:
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
mode advanced
|
||||
mode simple
|
||||
```
|
||||
@@ -46,7 +46,7 @@ open it, so a project set up for SQL practice reopens in advanced mode.
|
||||
When you are in simple mode and want to run a single SQL statement without
|
||||
switching, prefix the line with a colon:
|
||||
|
||||
```text
|
||||
```rdbms
|
||||
:select count(*) from books
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user