(args: string[])
| 299 | } |
| 300 | |
| 301 | yamlDirectiveHandler(args: string[]): string | null { |
| 302 | if (args.length !== 1) { |
| 303 | throw this.#createError( |
| 304 | "Cannot handle YAML directive: YAML directive accepts exactly one argument", |
| 305 | ); |
| 306 | } |
| 307 | |
| 308 | const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]!); |
| 309 | if (match === null) { |
| 310 | throw this.#createError( |
| 311 | "Cannot handle YAML directive: ill-formed argument", |
| 312 | ); |
| 313 | } |
| 314 | |
| 315 | const major = parseInt(match[1]!, 10); |
| 316 | const minor = parseInt(match[2]!, 10); |
| 317 | if (major !== 1) { |
| 318 | throw this.#createError( |
| 319 | "Cannot handle YAML directive: unacceptable YAML version", |
| 320 | ); |
| 321 | } |
| 322 | this.checkLineBreaks = minor < 2; |
| 323 | if (minor !== 1 && minor !== 2) { |
| 324 | this.dispatchWarning( |
| 325 | "Cannot handle YAML directive: unsupported YAML version", |
| 326 | ); |
| 327 | } |
| 328 | return args[0] ?? null; |
| 329 | } |
| 330 | tagDirectiveHandler(args: string[]) { |
| 331 | if (args.length !== 2) { |
| 332 | throw this.#createError( |
no test coverage detected