comark-steps
Steps
Turn the headings of a tutorial, or a numbered list, into numbered steps down a line. Nuxt UI's syntax, with no script.
Install the plugin
Section titled "Install the plugin"pnpm add comark-stepsRegister it
Section titled "Register it"Pass
steps()to the parser andcomponentsto the renderer.Write the steps
Section titled "Write the steps"Wrap the headings of a tutorial in
::steps.
::steps
### Install the plugin
```sh
pnpm add comark-steps
```
### Register it
Pass `steps()` to the parser and `components` to the renderer.
### Write the steps
Wrap the headings of a tutorial in `::steps`.
::- Fork the repository and clone it.
- Run
pnpm install. - Open a pull request against
main.
::steps
1. Fork the repository and clone it.
2. Run `pnpm install`.
3. Open a pull request against `main`.
::Each heading starts a step that holds everything up to the next one. The heading keeps its id, so links to it and the page's table of contents still work. Without the styles, the steps read as a numbered list.
Headings
Section titled "Headings"::steps{level="2"}
## Install
Run `pnpm add comark-steps`.
## Register
Pass `steps()` to the parser.
::| Prop | What it does |
|---|---|
level |
The level of the headings that start each step, from 2 to 6. Defaults to 3, so ### headings. Deeper headings stay inside their step. |
This is Nuxt UI's ::steps, unchanged, so a page renders the same steps under Nuxt UI.
A numbered list
Section titled "A numbered list"::steps
3. Open a pull request.
4. Wait for review.
::A block whose only content is a numbered list makes one step of each item, as Starlight's <Steps> does. A list that starts past 1 keeps its number.
Issues
Section titled "Issues"The plugin adds every problem to meta.issues, as Validation describes:
- Content before the first heading renders above the steps.
- A block with no headings at its
leveland no numbered list renders as plain content. When its headings are at another level, the issue names thelevelto write. - A
leveloutside 2 to 6 falls back to 3. - A prop other than
level, such asstart, is ignored.
Each issue names its block and says how to fix it. Each one has its own rule in Doctor.
Examples
Section titled "Examples"Anchors and the table of contents
Section titled "Anchors and the table of contents"The heading that starts a step stays a heading inside it, with the same id, so #install links, a table of contents built from the document, and comark-linter's anchor check all see it as before.
Steps inside a step
Section titled "Steps inside a step"A :::steps inside a step keeps its own headings and its own numbers:
Set up the database
Section titled "Set up the database"Start Postgres
Section titled "Start Postgres"Run the migrations
Section titled "Run the migrations"
Start the server
Section titled "Start the server"Run
pnpm dev.
::steps
### Set up the database
:::steps{level="4"}
#### Start Postgres
#### Run the migrations
:::
### Start the server
Run `pnpm dev`.
::The plugin takes no options. In comarkUi(), steps: false turns it off.
Your own renderer
Section titled "Your own renderer"The parse plugin replaces the block with a steps node holding one step per step, and writes each step's number as index, counted from the list's start:
["steps", { "start": "3" }, ["step", { "index": "3" }, "Open a pull request."]]start is there only when the steps start past 1. A component for step gets everything after the heading as its content, the heading included.
Package
Section titled "Package"comark-ui brings comark-steps and registers it. To use it alone, install it:
pnpm add comark @comark/html comark-stepsRegister the plugin and pass the renderer's components:
import { createHtmlRenderer } from "@comark/html";
import steps, { components } from "comark-steps/html";
const render = createHtmlRenderer({ plugins: [steps()], components });For Vue, React, or Svelte, import from comark-steps/vue, comark-steps/react, or comark-steps/svelte. The components add the styles when they mount. When you render on a server, import comark-steps/style.css with your own styles so the page doesn't shift. Renderers covers using it with other plugins.
Steps are an <ol class="cs"> of <li class="cs-step">, numbered with the CSS counter cs-step in a circle on ::before, and joined by a line on ::after. They read these shared tokens:
| Token | Used for |
|---|---|
--comark-foreground |
The numbers |
--comark-border |
The circles and the line |
--comark-accent |
Inside the circles |
--comark-font |
The numbers |
The rules sit in a comark CSS layer, so any plain rule of your own wins.