From 794b93625dd70ba35d0e7661306b8181c85f1db1 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Wed, 10 Oct 2018 22:33:59 +0900 Subject: [PATCH] add comments --- viewer/mj/mj.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/viewer/mj/mj.js b/viewer/mj/mj.js index 739194d73..6bfce9894 100644 --- a/viewer/mj/mj.js +++ b/viewer/mj/mj.js @@ -27,6 +27,10 @@ const svgToDataUrl = function (xml) { return b64Start + svg64; } +// We cannot know actual colors for each theme in extension process +// because VSCode API does not allow such operations. +// c.f., https://github.com/Microsoft/vscode/issues/32813 +// But we can know the colors in WebView process through CSS variables. const pickColor = function (prop) { m = prop.match(/rgb\((\d+), (\d+), (\d+)\)/) if (m) { @@ -85,6 +89,8 @@ const setVSCodeForegroundColor = function(tex) { const rgb = getVSCodeEditorForegound(); const color = '\\color[RGB]{' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + '}'; var ret = tex.replace(/^(\$|\\\(|\\begin{.*?}({.*?})*)/, '$1' + color); + // insert \color{ } after each & and \\ + // while skipping CD env ret = ret.replace(/(\\begin{CD}[\s\S]*?\\end{CD}|((?:\\[^\\]|[^&\\])*&+|\\\\))/g, '$1' + color); return ret; }