Skip to content

Commit 17c763f

Browse files
committed
merge custom parsers with default
1 parent ec2af4e commit 17c763f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "style-parser",
3-
"version": "1.0.1",
3+
"version": "1.0.0",
44
"description": "After Effects Expression Library",
55
"main": "dist/style-parser.jsx",
66
"scripts": {

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type ParsedSection = {
66

77
function parseStyles(
88
inputText: string,
9-
customParsers: Array<{ matcher: RegExp; stylename: string }>
9+
customParsers: Array<{ matcher: RegExp; stylename: string }> = []
1010
) {
1111
/** Split the input text into an array of lines */
1212
const inputLines = inputText.split(/[\r\n\3]/g);
@@ -42,7 +42,8 @@ function parseStyles(
4242
};
4343
}
4444

45-
const parsers = customParsers ?? [
45+
const parsers = [
46+
...customParsers,
4647
{ stylename: 'bold', matcher: new RegExp(/\*(.*)\*/) },
4748
{ stylename: 'italics', matcher: new RegExp(/_(.*)_/) },
4849
];
@@ -63,9 +64,14 @@ function parseStyles(
6364
return parsedStyles.flat();
6465
}
6566

67+
const defaultFontMap = {
68+
bold: 'Arial-BoldMT',
69+
italics: 'Arial-ItalicMT',
70+
};
71+
6672
// '_npmVersion' is replaced with value from package.json
6773
// during compilation
6874
const version: string = '_npmVersion';
6975

7076
// Export values to appear in jsx files
71-
export { parseStyles, version };
77+
export { parseStyles, defaultFontMap, version };

0 commit comments

Comments
 (0)