2017-05-30 162 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有這默認包括