Skip to content

---cut-end--- at line end is being ignored #76

@fuma-nama

Description

@fuma-nama

The error is produced when it ends with ---cut-end---:

// ---cut-start---
export class Foo {}
// ---cut-end---
TwoslashError: 
## Mismatched cut markers

You have 1 cut-starts and 0 cut-ends

Make sure you have a matching pair for each.
    at findCutNotations (file:///project/workspace/node_modules/twoslash/dist/shared/twoslash.CLSMoA24.mjs:290:11)
    at twoslasher2 (file:///project/workspace/node_modules/twoslash/dist/core.mjs:138:5)
    at file:///project/workspace/index.js:9:13
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12) {
  title: 'Mismatched cut markers',
  description: 'You have 1 cut-starts and 0 cut-ends',
  recommendation: 'Make sure you have a matching pair for each.',
  code: undefined
}

This can be reproduced on twoslash, or twoslash + Shiki:

import { createTwoslasher } from "twoslash";

const code =
  "console.log();\n// ---cut-start---\nexport class Foo {}\n// ---cut-end---";

const twoslasher = createTwoslasher();
console.log(twoslasher(code));

CodeSandbox: https://codesandbox.io/p/devbox/w22dfn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions