Skip to content

Commit

Permalink
feat(core): pass raw token to transformer.span api (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzuu666 authored Sep 26, 2024
1 parent 7602669 commit bba452c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/highlight/code-to-hast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function tokensToHast(
tokenNode.properties.style = style

for (const transformer of transformers)
tokenNode = transformer?.span?.call(context, tokenNode, idx + 1, col, lineNode) || tokenNode
tokenNode = transformer?.span?.call(context, tokenNode, idx + 1, col, lineNode, token) || tokenNode

if (structure === 'inline')
root.children.push(tokenNode)
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface ShikiTransformer {
/**
* Transform each token `<span>` element.
*/
span?: (this: ShikiTransformerContext, hast: Element, line: number, col: number, lineElement: Element) => Element | void
span?: (this: ShikiTransformerContext, hast: Element, line: number, col: number, lineElement: Element, token: ThemedToken) => Element | void
/**
* Transform the generated HTML string before returning.
* This hook will only be called with `codeToHtml`.
Expand Down

0 comments on commit bba452c

Please sign in to comment.