개발관련

how to vscode highlight HTML code syntax inside a string

개발자 Dane 2024. 10. 30. 10:40
반응형

javascript에서 html code를 string으로 제어하는 경우가 종종 있다.

 

이 경우에는 vscode가 일반적인 string으로 인식하기 때문에 code syntax highlight를 지원하지 않는다.

 

그래서 https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/raw 를 이용해서 

 

const html = String.raw

html`<html></html>`

 

이런식으로 사용했었는데 찾아보니 vscod에 해당 기능을 지원해주는 플러그인이 있더라

 

 

https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html

 

es6-string-html - Visual Studio Marketplace

Extension for Visual Studio Code - Syntax highlighting in es6 multiline strings

marketplace.visualstudio.com

 

/*html*/



/*html*/`<html></html>`

이런식으로 string앞에 주석만 추가해주면 된다.

 

html 이외에도

  • /*css*/
  • /*html*/
  • /*inline-html*/
  • /*template*/
  • /*inline-template*/
  • /*javascript*/ or /*js*/
  • /*typescript*/ or /*ts*/

등 많은 언어를 지원해준다.

반응형