Repository navigation
skipped-code: add [!code skip], a marker for code that a block leaves out - #39
Merged
Merged
Conversation
…es out A dotted rule with a badge takes the place of the directive line, at its indentation. The badge reads "Code not shown", or the text after the directive. The marker is static HTML and stays out of the copied text. A directive on its own line at the end of a block puts the marker after the last line, through a new `endOfBlock` directive setting. `skippedCode: false` turns the feature off. Part of #28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as `[!code skip]` A comment that holds only an alias, or the alias alone on its line in a language with no comment syntax such as JSON, gives the marker. `skippedCode.aliases` sets the aliases (default `['...']`). A bare `...` in Python or YAML stays code, and a language set to `[]` in `notation.comments` reads no aliases. `commentSyntaxFor` now returns `undefined` for a language with no comment syntax. Also adds the changelog entry for skipped code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er texts with "Not shown: " The alias note goes in a tip aside. The README image is regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nts in the parser A language with no entry in the comment table may still have comments (F#, Elixir), so bare `...` there stays code. The notation parser now keeps each directive's indentation, which drops the skip plugin's own hook, and it trims aliases once and exits early on blocks whose only `...` is code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n runs, diffs and at the end of a block - `skippedCode.aliases` defaults to `[]`, because `// ...` lines that leave the code move the ranges of existing pages. The docs, the skill and the changelog explain the opt-in and what it changes. - A marker between hidden lines hides and shows with them. - Markers at the end of a block keep their source order, and go after the last line of code, not after output lines. - In diff blocks, a skip line with a `+` or `-` prefix is read, at the indentation that readers see. - Hidden lines and skipped code share their marker colours and styles, so skipped code also clears the copy button on touch screens. - `commentSyntaxFor()` returns an array again, and `hasNoComments()` tells JSON apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly when a site uses them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n section Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nguage
A `[!code skip]` line now stays a line of the block: it keeps its line
number, ranges count it, and it copies as a plain comment (`// text`, or
`// ...`). The comment stays in the line, clipped and `aria-hidden`, and
the badge is drawn after the indentation. This removes the special cases
for markers at the end of a block, in hidden runs, after output and in
print. The directive warns with a count or on a line with code.
`skippedCode.aliases` becomes `commentAliases` and `bareAliases`, maps by
language with `*` for the rest, merged over the defaults
`{ '*': ['...'] }` and `{ json: ['...'] }`.
Also caches the merged directive specs per site, uses one diff prefix
rule, and types the marker style settings without casts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to the skipped code page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d directives and walkthroughs - Read a `+` or `-` prefix in the second parse only in a real diff, which Expressive Code leaves as written - Replace only the code of a skip line, so line state labels and messages stay - Give no warning for an alias such as `# ...` in output or run code - Give the text of a dropped `[!code skip]` to the next directive that takes text - Read a skip line as its comment in readTokens, and skip the walkthrough animation when a skip marker shows - Check each line for an alias before the full parse, not any `...` in the block - Remove the unused insertAfter and a stale order comment, reuse diffLine, and keep hidden line positioning out of markerStyles - Rewrite the CHANGELOG entry for the current design Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the "code skipped" marker from #28. It shows where a code block leaves out code, in place of a
// ...comment that readers can mistake for code. Authors write the[!code skip]directive, with optional text. A site can also read its existing// ...comments as markers, withskippedCode.aliases: ['...']. This is off by default, because it changes existing pages.Changes
[!code skip][!output]or[!run]lines. Several markers there keep their source order.+or-prefix works, and the marker takes the indentation that readers see.skippedCode: falseturns the feature off....lines, opt-inskippedCode.aliasesdefaults to[]. With['...'], a comment that holds only...(// ...,# ...,/* ... */,<!-- ... -->) is the same as[!code skip]....alone on its line is the same....in a language with comments stays code: it is the ellipsis in Python and the end of a document in YAML. A comment with more text, such as// ... and so on, also stays, which keeps a// ...as code in one block.[!code skip] text.['...'], for the JSON example.endOfBlock. A directive line at the end of the block then applies after the last line, in place of the warning "has no line below it". Only[!code skip]sets it.aliases, read as described above.hasNoComments()incomments.tstells JSON apart, unless the site gives it a comment syntax.commentSyntaxFor()is unchanged. A language set to[]innotation.commentsreads no directives and no aliases.core.tsgetsinsertAfter()next toinsertBefore().markerColoursandmarkerStylesinstyles.ts. Each keeps its own settings group.DECISIONS.mdand the changelog are updated. The feature count is now 29.Design notes
// ...lines leave the code, so every line range after them, such as{4}orins={4}, counts different lines. Their walkthrough steps also stop animating. On by default, that changes pages that never asked for the feature.// ...as code.skip={range}...alias covers JSON instead.:Nas a count of skipped lines, where every other directive reads:Nas the lines it applies to.Checks
pnpm lint,pnpm lint:docs,pnpm test(597 unit tests and the script tests) andpnpm docs:buildpass with no warnings.Closes #28
🤖 Generated with Claude Code