Skip to content

Commit 0fb6ed2

Browse files
committed
Support plist themes
1 parent 9c75869 commit 0fb6ed2

File tree

4 files changed

+77
-8
lines changed

4 files changed

+77
-8
lines changed

scripts/scrapeBuiltinExtensions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const util = require('util');
44
const glob = require('glob');
55
const path = require('path');
66
const processExtension = require('../src/processExtension');
7-
const { requireGrammar } = require('../src/utils');
7+
const { requirePlistOrJson } = require('../src/utils');
88

99
const copyFile = util.promisify(fs.copyFile);
1010
const writeFile = util.promisify(fs.writeFile);
@@ -30,13 +30,13 @@ glob(path.resolve(__dirname, '../vscode/extensions/*/package.json'), async (err,
3030
...await newManifestPromise,
3131
...await Object.keys(extension.grammars).reduce(async (newManifestPromise, scopeName) => {
3232
const grammar = extension.grammars[scopeName];
33-
const content = await requireGrammar(grammar.path);
33+
const content = await requirePlistOrJson(grammar.path);
3434
let destPath = grammarPath(path.basename(grammar.path));
3535
const newContent = processTmJson(content);
3636
// Different languages are sometimes named the same thing
3737
languageId++;
3838
if (await exists(destPath)) {
39-
const existingGrammar = await requireGrammar(destPath);
39+
const existingGrammar = await requirePlistOrJson(destPath);
4040
if (existingGrammar.scopeName !== scopeName) {
4141
const [baseName, ...ext] = path.basename(grammar.path).split('.');
4242
const renamed = [baseName, languageId, ...ext].join('.');

src/processExtension.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
const path = require('path');
3-
const { getLanguageNames, requireJson, requireGrammar } = require('./utils');
3+
const { getLanguageNames, requireJson, requirePlistOrJson } = require('./utils');
44

55
async function processExtension(packageJsonPath) {
66
const packageJson = requireJson(packageJsonPath);
@@ -10,7 +10,7 @@ async function processExtension(packageJsonPath) {
1010
const manifest = await Promise.all(
1111
packageJson.contributes.grammars.map(async grammar => {
1212
const sourcePath = path.resolve(path.dirname(packageJsonPath), grammar.path);
13-
const content = await requireGrammar(sourcePath);
13+
const content = await requirePlistOrJson(sourcePath);
1414
const { scopeName } = content;
1515
const languageRegistration = packageJson.contributes.languages.find(l => l.id === grammar.language);
1616

@@ -44,7 +44,7 @@ async function processExtension(packageJsonPath) {
4444
const manifest = await Promise.all(
4545
packageJson.contributes.themes.map(async theme => {
4646
const sourcePath = path.resolve(path.dirname(packageJsonPath), theme.path);
47-
const themeContents = requireJson(sourcePath);
47+
const themeContents = await requirePlistOrJson(sourcePath);
4848
return {
4949
id: theme.id || path.basename(theme.path).split('.')[0],
5050
path: sourcePath,

src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function sanitizeForClassName(str) {
7272

7373
const readFile = util.promisify(fs.readFile);
7474
const requireJson = /** @param {string} pathName */ pathName => JSON5.parse(fs.readFileSync(pathName, 'utf8'));
75-
const requireGrammar = /** @param {string} pathName */ async pathName =>
75+
const requirePlistOrJson = /** @param {string} pathName */ async pathName =>
7676
path.extname(pathName) === '.json' ? requireJson(pathName) : plist.parse(await readFile(pathName, 'utf8'));
7777

7878
module.exports = {
@@ -83,5 +83,5 @@ module.exports = {
8383
getLanguageNames,
8484
sanitizeForClassName,
8585
requireJson,
86-
requireGrammar
86+
requirePlistOrJson
8787
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<pre class="oceanic-next vscode-highlight" data-language="js"><code class="vscode-highlight-code"><span class="vscode-highlight-line"><span class="mtk7">console</span><span class="mtk5">.</span><span class="mtk8">log</span><span class="mtk1">(</span><span class="mtk5">"</span><span class="mtk6">Hello, world!</span><span class="mtk5">"</span><span class="mtk1">)</span><span class="mtk5">;</span></span></code></pre>
2+
<style class="vscode-highlight-styles">:root {
3+
--vscode-highlight-padding-v: 1rem;
4+
--vscode-highlight-padding-h: 1.5rem;
5+
--vscode-highlight-padding-top: var(--vscode-highlight-padding-v);
6+
--vscode-highlight-padding-right: var(--vscode-highlight-padding-h);
7+
--vscode-highlight-padding-bottom: var(--vscode-highlight-padding-v);
8+
--vscode-highlight-padding-left: var(--vscode-highlight-padding-h);
9+
--vscode-highlight-border-radius: 8px;
10+
11+
--vscode-highlight-line-highlighted-background-color: transparent;
12+
--vscode-highlight-line-highlighted-border-width: 4px;
13+
--vscode-highlight-line-highlighted-border-color: transparent;
14+
}
15+
16+
.vscode-highlight {
17+
overflow: auto;
18+
-webkit-overflow-scrolling: touch;
19+
padding-top: 1rem;
20+
padding-top: var(--vscode-highlight-padding-top);
21+
padding-bottom: 1rem;
22+
padding-bottom: var(--vscode-highlight-padding-bottom);
23+
border-radius: 8px;
24+
border-radius: var(--vscode-highlight-border-radius);
25+
font-feature-settings: normal;
26+
}
27+
28+
.vscode-highlight-code {
29+
display: inline-block;
30+
min-width: 100%;
31+
}
32+
33+
.vscode-highlight-line {
34+
display: inline-block;
35+
box-sizing: border-box;
36+
width: 100%;
37+
padding-left: 1.5rem;
38+
padding-left: var(--vscode-highlight-padding-left);
39+
padding-right: 1.5rem;
40+
padding-right: var(--vscode-highlight-padding-right);
41+
}
42+
43+
.vscode-highlight-line-highlighted {
44+
background-color: var(--vscode-highlight-line-highlighted-background-color);
45+
box-shadow: inset var(--vscode-highlight-line-highlighted-border-width) 0 0 0 var(--vscode-highlight-line-highlighted-border-color);
46+
}
47+
.oceanic-next {
48+
background-color: #1B2B34;
49+
color: #CDD3DE;
50+
}
51+
52+
.oceanic-next .mtk1 { color: #CDD3DE; }
53+
.oceanic-next .mtk2 { color: #1B2B34; }
54+
.oceanic-next .mtk3 { color: #65737E; }
55+
.oceanic-next .mtk4 { color: #F99157; }
56+
.oceanic-next .mtk5 { color: #5FB3B3; }
57+
.oceanic-next .mtk6 { color: #99C794; }
58+
.oceanic-next .mtk7 { color: #FAC863; }
59+
.oceanic-next .mtk8 { color: #6699CC; }
60+
.oceanic-next .mtk9 { color: #D8DEE9; }
61+
.oceanic-next .mtk10 { color: #EC5F67; }
62+
.oceanic-next .mtk11 { color: #EB606B; }
63+
.oceanic-next .mtk12 { color: #BB80B3; }
64+
.oceanic-next .mtk13 { color: #C594C5; }
65+
.oceanic-next .mtk14 { color: #AB7967; }
66+
.oceanic-next .mtk15 { color: #F2777A; }
67+
.oceanic-next .mtki { font-style: italic; }
68+
.oceanic-next .mtkb { font-weight: bold; }
69+
.oceanic-next .mtku { text-decoration: underline; text-underline-position: under; }</style>

0 commit comments

Comments
 (0)