Note kit command

text.find

Find text

Finds text (or a regular expression with `regex: true`) in the note's body (the front matter is not searched: read properties with `property.list`) and answers each match's `from`, `to`, line and text. The way to get text positions for `text.insert`, `text.replace` and `comment.add`.

Kit
Note 0.3.0 (Markdown (.md))
Changes the document
no

Parameters

Parameters of text.find
NameTypeRequiredDescription
caseSensitivebooleannoMatch case.
findstringyesThe text, or a regular expression with regex.
limitintegernoThe most matches to answer (default 100).
regexbooleannoRead find as a regular expression (Rust syntax).
unit"scalar" | "utf16"noHow positions are counted: Unicode characters (scalar, the default), or UTF-16 code units as the editor counts them.

Call through note_run

text
note_run {
  "path": "<file>.md",
  "steps": [{ "command": "text.find", "params": { "find": <string> } }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: caseSensitive, limit, regex, unit. note_run answers the step’s result in completed[i].result.

Result

Result of text.find
NameTypeRequiredDescription
countintegeryesHow many matches are answered.
matchesobject[]yesThe matches, in document order.
morebooleanyesWhether there are more than limit.
Result JSON Schema
json
{
  "additionalProperties": false,
  "properties": {
    "count": {
      "description": "How many matches are answered.",
      "type": "integer"
    },
    "matches": {
      "description": "The matches, in document order.",
      "items": {
        "additionalProperties": false,
        "properties": {
          "from": {
            "description": "Where it starts, in the request's unit.",
            "type": "integer"
          },
          "line": {
            "description": "Its line, from 1.",
            "type": "integer"
          },
          "text": {
            "description": "The text matched.",
            "type": "string"
          },
          "to": {
            "description": "Where it ends (exclusive).",
            "type": "integer"
          }
        },
        "required": [
          "from",
          "line",
          "text",
          "to"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "more": {
      "description": "Whether there are more than limit.",
      "type": "boolean"
    }
  },
  "required": [
    "count",
    "matches",
    "more"
  ],
  "type": "object"
}

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "caseSensitive": {
      "default": true,
      "description": "Match case.",
      "type": "boolean"
    },
    "find": {
      "description": "The text, or a regular expression with regex.",
      "type": "string"
    },
    "limit": {
      "description": "The most matches to answer (default 100).",
      "type": "integer"
    },
    "regex": {
      "description": "Read find as a regular expression (Rust syntax).",
      "type": "boolean"
    },
    "unit": {
      "default": "scalar",
      "description": "How positions are counted: Unicode characters (scalar, the default), or UTF-16 code units as the editor counts them.",
      "enum": [
        "scalar",
        "utf16"
      ],
      "type": "string"
    }
  },
  "required": [
    "find"
  ],
  "type": "object"
}

Generated from kition-sdk packages/script/kits/note.ts and the kit itself (kition-note@69e14d9). As data: commands.jsonl.