@shikijs/primitive
Advanced tools
+6
-5
@@ -620,3 +620,3 @@ import { ShikiError } from "@shikijs/types"; | ||
| const colorReplacements = resolveColorReplacements(theme, options); | ||
| const { tokenizeMaxLineLength = 0, tokenizeTimeLimit = 500 } = options; | ||
| const { tokenizeMaxLineLength = 0, tokenizeTimeLimit = 500, includeExplanation = false } = options; | ||
| const lines = splitLines(code); | ||
@@ -650,3 +650,3 @@ let stateStack = options.grammarState ? getGrammarStack(options.grammarState, theme.name) ?? INITIAL : options.grammarContextCode != null ? _tokenizeWithTheme(options.grammarContextCode, grammar, theme, colorMap, { | ||
| let tokensWithScopesIndex; | ||
| if (options.includeExplanation) { | ||
| if (includeExplanation && includeExplanation !== "tokenType") { | ||
| resultWithScopes = grammar.tokenizeLine(line, stateStack, tokenizeTimeLimit); | ||
@@ -671,5 +671,6 @@ tokensWithScopes = resultWithScopes.tokens; | ||
| }; | ||
| if (options.includeExplanation) { | ||
| if (includeExplanation === "tokenType") token.type = EncodedTokenMetadata.getTokenType(metadata); | ||
| else if (includeExplanation) { | ||
| const themeSettingsSelectors = []; | ||
| if (options.includeExplanation !== "scopeName") for (const setting of theme.settings) { | ||
| if (includeExplanation !== "scopeName") for (const setting of theme.settings) { | ||
| let selectors; | ||
@@ -698,3 +699,3 @@ switch (typeof setting.scope) { | ||
| content: tokenWithScopesText, | ||
| scopes: options.includeExplanation === "scopeName" ? explainThemeScopesNameOnly(tokenWithScopes.scopes) : explainThemeScopesFull(themeSettingsSelectors, tokenWithScopes.scopes) | ||
| scopes: includeExplanation === "scopeName" ? explainThemeScopesNameOnly(tokenWithScopes.scopes) : explainThemeScopesFull(themeSettingsSelectors, tokenWithScopes.scopes) | ||
| }); | ||
@@ -701,0 +702,0 @@ tokensWithScopesIndex += 1; |
+2
-2
| { | ||
| "name": "@shikijs/primitive", | ||
| "type": "module", | ||
| "version": "4.3.0", | ||
| "version": "4.3.1", | ||
| "description": "Tokenizer primitives of Shiki", | ||
@@ -49,3 +49,3 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
| "@types/hast": "^3.0.4", | ||
| "@shikijs/types": "4.3.0" | ||
| "@shikijs/types": "4.3.1" | ||
| }, | ||
@@ -52,0 +52,0 @@ "scripts": { |
39684
0.35%840
0.12%+ Added
- Removed
Updated