-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade to vscode-textmate-v7. fix #343
- Loading branch information
Showing
7 changed files
with
96 additions
and
9,009 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"tokenColors": [ | ||
{ | ||
"name": "Keyword", | ||
"scope": "keyword", | ||
"settings": { | ||
"foreground": "#ffffff", | ||
"fontStyle": "bold" | ||
} | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/shiki/src/__tests__/custom-fonts/font-italic.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"tokenColors": [ | ||
{ | ||
"name": "Keyword", | ||
"scope": "keyword", | ||
"settings": { | ||
"foreground": "#ffffff", | ||
"fontStyle": "italic" | ||
} | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"tokenColors": [ | ||
{ | ||
"name": "Keyword", | ||
"scope": "keyword", | ||
"settings": { | ||
"foreground": "#ffffff" | ||
} | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import path from 'path' | ||
import { getHighlighter, loadTheme } from '../index' | ||
|
||
test('No font-style is applied if none is specified', async () => { | ||
const fNone = await loadTheme(path.resolve(__dirname, './custom-fonts/font-none.json')) | ||
const highlighter = await getHighlighter({ | ||
theme: fNone, | ||
langs: ['js'] | ||
}) | ||
const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' }) | ||
|
||
expect(out).not.toContain('font-style:') | ||
}) | ||
|
||
test('An italic font-style is applied if specified', async () => { | ||
const fItalic = await loadTheme(path.resolve(__dirname, './custom-fonts/font-italic.json')) | ||
const highlighter = await getHighlighter({ | ||
theme: fItalic, | ||
langs: ['js'] | ||
}) | ||
const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' }) | ||
|
||
expect(out).toContain('font-style: italic') | ||
}) | ||
|
||
test('A bold font-style is applied if specified', async () => { | ||
const fBold = await loadTheme(path.resolve(__dirname, './custom-fonts/font-bold.json')) | ||
const highlighter = await getHighlighter({ | ||
theme: fBold, | ||
langs: ['js'] | ||
}) | ||
// console.log(JSON.stringify(highlighter.codeToThemedTokens(`function() {return 1}`, 'js'), null, 2)) | ||
const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' }) | ||
|
||
expect(out).toContain('font-weight: bold') | ||
}) | ||
|
||
test('A bold fontStyle should not apply an italic font-style', async () => { | ||
const fBold = await loadTheme(path.resolve(__dirname, './custom-fonts/font-bold.json')) | ||
const highlighter = await getHighlighter({ | ||
theme: fBold, | ||
langs: ['js'] | ||
}) | ||
const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' }) | ||
|
||
expect(out).not.toContain('font-style: italic') | ||
}) |
Oops, something went wrong.