Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

feat(transformers): Support word highlighting across multiple tokens #116

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ee6e48b
Support word highlighting
fuma-nama Jan 13, 2024
6772afa
Update tests & docs
fuma-nama Jan 13, 2024
243c29d
Ignore whitespaces in span elements
fuma-nama Jan 13, 2024
d214d8c
Split whitespace & highlighted span
fuma-nama Jan 13, 2024
0968a52
feat: Support filtering meta string before processing highlights
fuma-nama Jan 14, 2024
4ec5d16
feat: Support word highlighting for rehype & markdown-it
fuma-nama Jan 14, 2024
4fc7ed9
Merge branch 'main' into main
fuma-nama Jan 14, 2024
b80c531
feat(transformers): Support `transformerNotationWordHighlight`
fuma-nama Jan 14, 2024
69ba597
Merge branch 'main' of https://github.com/fuma-nama/shikiji
fuma-nama Jan 14, 2024
b4ff342
Merge branch 'main' of https://github.com/antfu/shikiji into antfu-main
fuma-nama Jan 14, 2024
2fe47d7
Merge branch 'antfu-main'
fuma-nama Jan 14, 2024
86c20b8
Remove conflicts
fuma-nama Jan 14, 2024
245aad9
Remove legacy docs
fuma-nama Jan 15, 2024
ebd2f7b
Merge branch 'main' into main
fuma-nama Jan 15, 2024
3785cbf
Discard changes to docs/packages/rehype.md
antfu Jan 15, 2024
1fbae06
Discard changes to docs/.vitepress/config.ts
antfu Jan 15, 2024
4c611d3
Merge branch 'antfu:main' into main
fuma-nama Jan 16, 2024
8ac236d
Update syntax
fuma-nama Jan 16, 2024
dd56021
Implement `transformerMetaWordHighlight` transformer
fuma-nama Jan 17, 2024
2fc4ad6
Update docs
fuma-nama Jan 17, 2024
7d915ad
Merge branch 'main' into pr/fuma-nama/92
antfu Jan 17, 2024
4ad0755
chore: refactor
antfu Jan 17, 2024
ff9619f
chore: refactor
antfu Jan 17, 2024
e7f3216
chore: docs update
antfu Jan 17, 2024
4d3e5b3
feat: remove empty line
antfu Jan 17, 2024
a48b3cb
chore: avoid using structure clone
antfu Jan 17, 2024
54bea1b
Merge branch 'main' of https://github.com/fuma-nama/shikiji
fuma-nama Jan 26, 2024
0cac5a7
Support highlighting across multiple tokens
fuma-nama Jan 26, 2024
22d89a8
Remove empty lines
fuma-nama Jan 26, 2024
01080d9
Fix implicit external error
fuma-nama Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: refactor
antfu committed Jan 17, 2024
commit 4ad0755792d65f249cd1986b51f8c5dcf2d9257e
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ShikijiTransformer, addClassToHast } from 'shikiji'
import { createCommentNotationTransformer } from '../utils'
import { highlightWordInLine } from '../highlight-word'
import { highlightWordInLine } from '../shared/highlight-word'

export interface TransformerNotationWordHighlightOptions {
/**
@@ -28,7 +28,7 @@ export function transformerNotationWordHighlight(
const lineNum = range ? Number.parseInt(range.slice(1), 10) : lines.length

lines
// Don't include the comment itself
// Don't include the comment itself
.slice(index + 1, index + 1 + lineNum)
.forEach(line => highlightWordInLine(line, comment, word, classActiveWord))

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ShikijiTransformer } from 'shikiji'
import { highlightWordInLine } from '../highlight-word'
import { highlightWordInLine } from '../shared/highlight-word'

export function parseMetaHighlightWords(meta: string): string[] {
if (!meta)