2017-05-30 163 views

回答

1

因为你的编辑器无法识别text/paperscript MIME类型,它不知道什么语法高亮适用于它。

为了避免这种情况,您最好的办法是将您的paperscript代码存储在一个单独的文件中,其扩展名为.js。然后你的编辑器会自动将正确的JS语法突出显示给它。

的index.html

<script type="text/paperscript" canvas="myCanvas" src="index.js"></script> 

index.js

// exactly the same code you had inline before 
for (var x = 0; x < 1000; x += 100) { 

    for (var y = 0; y < 1000; y += 100) { 

     var myCircle = new Path.Circle(new Point(x, y), 10); 
     myCircle.fillColor = 'purple'; 

    } 
} 
0

类似的问题再文/巴别在这里提出:https://github.com/Microsoft/vscode/issues/11781

你要做的是什么找到默认的VSCode html.json文件并制作一个小的edi牛逼

在Windows这将是这样的:C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\html\syntaxes\html.json

在Mac上,你必须要找到你的应用程序文件夹中的VSCode应用程序,然后右键单击“显示包内容”,并导航到/Contents/Resources/app/extensions/html/syntaxes/html.json

你应该找到这样一个代码块(搜索javascript

{ 
 
    "begin": "\\G", 
 
    "end": "(?i:(?=/?>|type(?=[\\s=])(?!\\s*=\\s*('|\"|)(text/(javascript|ecmascript|babel)|application/((x-)?javascript|ecmascript|babel)|module)[\\s\"'>])))", 
 
    "name": "meta.tag.metadata.script.html", 
 
    "patterns": [ 
 
    { 
 
     "include": "#tag-stuff" 
 
    } 
 
    ] 
 
},

只需添加paperscript的正则表达式这样

{ 
 
    "begin": "\\G", 
 
    "end": "(?i:(?=/?>|type(?=[\\s=])(?!\\s*=\\s*('|\"|)(text/(javascript|ecmascript|babel|paperscript)|application/((x-)?javascript|ecmascript|babel|paperscript)|module)[\\s\"'>])))", 
 
    "name": "meta.tag.metadata.script.html", 
 
    "patterns": [ 
 
    { 
 
     "include": "#tag-stuff" 
 
    } 
 
    ] 
 
},

保存html.json并重新启动VSCode,你应该是好去。

我已经提出请求https://github.com/textmate/html.tmbundle/issues有这默认包括