Markup definition
Detects steps from a file. Use regex to match the file’s raw text, one selector kind to match parsed nodes, or a kind with regex to match inside the selected nodes.
Referenced In
Fields
| Field | Type | Description | Default |
|---|---|---|---|
| name | string | Optional. Name of the markup definition | — |
| regex | one of: - string - array of string | Optional. Regular expressions to match. Alone, they run on the file’s raw text. With a selector kind, they run on each selected node’s main text, and each occurrence is a match. A node’s main text is its content, else its text, else its alt. | — |
| comment | object | Optional. Selects comments. | — |
| codeBlock | one of: - string - object | Optional. Selects code blocks. A string selects one language. | — |
| link | object | Optional. Selects links. | — |
| image | object | Optional. Selects images. | — |
| strong | object | Optional. Selects bold text. | — |
| emphasis | object | Optional. Selects italic text. | — |
| text | object | Optional. Selects runs of prose, outside code, links, and formatting. | — |
| element | one of: - string - object | Optional. Selects elements, such as HTML tags, XML elements, and JSX components. A string selects one tag. | — |
| captures | array of string | Optional. Fields of each match to use as $1, $2, and so on, in order. Without it, a selector definition uses its regex groups, else the node’s main text. A match.<n> field needs regex on the same definition. | — |
| batchMatches | boolean | Optional. If true, all matches are combined into a single string. | false |
| actions | one of: - string - array of one of: string, object | Optional. Actions to perform when the markup type is detected. An action name uses $1 as its value. An object is a step template: $1, $2, and so on are replaced, and the result is checked as a step when it’s detected. A step that isn’t valid is skipped with a warning. | — |
Examples
{"name": "runBash","codeBlock": "bash","actions": [{"runShell": "$1"}]}
{"name": "goToLink","link": {"url": "^https?://","precededBy": "\\b[Gg]o to\\s+$"},"captures": ["url"],"actions": ["goTo"]}
{"name": "version","text": {},"regex": "\\bv(\\d+\\.\\d+)\\b","actions": ["find"]}
{"name": "apiCall","regex": ["API:\\s*(GET|POST)\\s+`([^`]+)`"],"actions": [{"httpRequest": {"method": "$1","url": "$2"}}]}