Skip to content

Commit

Permalink
fix(non-italic-variants): remove italics from fontStyle only
Browse files Browse the repository at this point in the history
  • Loading branch information
mvllow committed Apr 5, 2023
1 parent 3447cce commit adeb230
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ const parseVariant = (

if (options.includeNonItalicVariants) {
const removeItalics = JSON.stringify(parsedTheme).replace(
/\s?italic\s?/g,
'',
/(fontStyle":\s*?"[^.]*?)(italic)([^.]*?")/g,
'$1$3',
);
const parsedNonItalicTheme = {
...(JSON.parse(removeItalics) as Theme),
Expand Down
6 changes: 6 additions & 0 deletions source/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const init = async (source: string) => {
\t\t\t\t"foreground": "$foreground",
\t\t\t\t"fontStyle": "italic"
\t\t\t}
\t\t},
\t\t{
\t\t\t"scope": "markup.italic.markdown",
\t\t\t"settings": {
\t\t\t\t"fontStyle": "italic"
\t\t\t}
\t\t}
\t]
}`,
Expand Down
2 changes: 2 additions & 0 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ test('includes non-italic variants', async (t) => {

t.notRegex(theme1, /fontStyle.*?italic/g);
t.notRegex(theme2, /fontStyle.*?italic/g);
// Ensure scope names are left unmodified
t.regex(theme2, /markup\.italic\.markdown/g);
});

test('removes empty values', async (t) => {
Expand Down

0 comments on commit adeb230

Please sign in to comment.