diff --git a/package-lock.json b/package-lock.json index ebfdefa..ea52ad5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "vscode-math-to-image", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.1.0", + "name": "vscode-math-to-image", + "version": "0.1.1", "license": "MIT", "dependencies": { "mathjax": "^3.1.2", @@ -506,7 +507,6 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", diff --git a/package.json b/package.json index a2ff913..c5232ad 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,16 @@ "type": "string", "default": "background: white;", "description": "Optional style for rendered display SVG equations. (Only supported when inserting as HTML)" + }, + "vscode-math-to-image.backgroundColor": { + "type": "string", + "default": "white", + "description": "Optional background color for rendered equations. (Only supported when inserting as HTML)" + }, + "vscode-math-to-image.fontColor": { + "type": "string", + "default": "black", + "description": "Optional font color for rendered equations. (Only supported when inserting as HTML)" } } } diff --git a/src/extension.ts b/src/extension.ts index 4f28362..864407a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -164,6 +164,12 @@ function insertMathImage(renderedImagePath: string, start: vscode.Position, end: vscode.window.showInformationMessage(`Render equation successfully!`) } +function setSvgColor(equation: string) { + const fontColor = vscode.workspace.getConfiguration().get("vscode-math-to-image.fontColor") + const backgroundColor = vscode.workspace.getConfiguration().get("vscode-math-to-image.backgroundColor") + return `\\color{${fontColor}}\\bbox[${backgroundColor}]{${equation}}` +} + /** * Render function to insert image form of the selected equation into current editor * @@ -183,7 +189,7 @@ function renderEntry(renderType: RenderType) { } else { if (displayMath.test(selection)) { // Remove leading $$ and trailing $$ - const equation = selection.split('\n').slice(1, -1).join('\n') + const equation = setSvgColor(selection.split('\n').slice(1, -1).join('\n')) const renderedImage = renderType === RenderType.REMOTE @@ -192,7 +198,7 @@ function renderEntry(renderType: RenderType) { insertMathImage(renderedImage, selectionStart, selectionEnd, MathType.DISPLAY) } else if (inlineMath.test(selection)) { // Remove leading $ and trailing $ - const equation = selection.slice(1, -1).trim() + const equation = setSvgColor(selection.slice(1, -1).trim()) const renderedImage = renderType === RenderType.REMOTE