Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format HTML tags and Javascript inside CDATA on XML document on Visual Basic / Code

I have XML Documents with html and javascript code written between CDATA. for example:

<element active='yes' type='Html' instance='LOGO'>
    <body>
        <![CDATA[
            <div class="logos" id="logos">
                <img class="float_right" src='mylogo.png' />
            </div>
        ]]>
    </body>
</element>

Another example:

<element active="yes" type="Html" >
    <![CDATA[
        <script>
            //Some javascript code
    </script>]]>
</element>

I want my IDE (Visual Studio or VSCode) to recognize my text between CDATA as HTML/Javascript code, and format the code. Do you know any solution for this? I tried to find some extention that do it, but couldent find anything.

like image 543
Iftah Saar Avatar asked Dec 05 '25 21:12

Iftah Saar


1 Answers

I have found the solution:

Change <!\[CDATA\[ to <!\[CDAT A\[ in file

C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\xml\syntaxes\xml.tmLanguage.json

Now XML wouldn't find <![CDATA[ :)

I also made similar changes in Emmet config:

C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\emmet\dist\node\emmetNodeMain.js

Make this files 'Read only' in Properties to have no problems after the next VS update.

like image 66
Webfeya Avatar answered Dec 07 '25 10:12

Webfeya