vigiles API reference
    Preparing search index...

    Function commandsIn

    • Command lines in md's fenced blocks that match matching.

      Comment lines (#) are skipped: a commented-out example is not a command the reader is told to run, and flagging it teaches people to delete their examples.

      🔴 THE FILTER IS RE-BUILT WITHOUT g/y, BECAUSE RegExp.test IS STATEFUL. On a global or sticky regex test() advances lastIndex, so testing a run of matching lines with the SAME object alternates hit/miss. Measured 2026-08-11 on four curl lines: /curl/ finds all four, /curl/g finds the 1st and the 3rd, /curl/y the same. Silent, and the wrong way round — half the document quietly leaves the set that mustInclude/mustNotInclude then judge, so the rule passes over commands it never saw. /curl/g is what a caller writes without thinking, and it must not mean something different.

      A fresh regex rather than resetting lastIndex: the caller's object is theirs and may be reused elsewhere, and there is no state left to reset wrongly. y goes too — sticky ANCHORS the match at lastIndex, so /curl/y against sudo curl … would find nothing, which is not what "matching" means here.

      Parameters

      • md: string
      • matching: RegExp

      Returns DocCommand[]