You Old Fool
You Old Fool

Reputation: 22941

Ignore CDATA tags for syntax highlighting in Sublime Text 3

I frequently use Sublime Text for editing vQmod code. For those that don't know, vQmod is a dynamic search/replace application that uses XML to modify the core files in OpenCart dynamically. Both the search position and the code to be added are typically contained within CDATA tags. Understandably, all syntax highlighting rules regard anything within CDATA tags as a block of plain text with no language rules applied. But in this case, the code contained therein can be HTML, PHP, JavaScript or inline CSS.

Is there a way I can modify the syntax highlighting rules so that text contained within the CDATA tags will still be evaluated as code?

Here is an example:

<operation>
    <search position="after"><![CDATA[public function index()]]></search>
    <add><![CDATA[
        $data['examples'] = $this->model_extension_extension->getExamples();
    ]]>
    </add>
</operation>

The <search> code is less important, but I would whatever lies within <add><![CDATA[ and ]]></add> to be recognized as php. Sometimes these are extremely long blocks code and having the proper syntax highlighting here would really help.

Upvotes: 1

Views: 426

Answers (1)

CalebC
CalebC

Reputation: 952

I encountered this issue as well as the entire CDATA section is my HTML. My workaround is to open the document with syntax type SCALA. RUBY works as well, but I think SCALA is highlighting is more relevant.

Upvotes: 5

Related Questions