Disable syntax highlighting for CDATA


#1

I use Atom editor and I have a template files with nested HTML in CDATA tag, so all HTML code is like 1 color.

Is possible to “ignore” CDATA? I want HTML syntax highlighting in that CDATA (see example). I cannot remove that CDATA because of template engine.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<template>
    <header>
    </header>

    <entity id="main"><![CDATA[
         <div>LOT OF HTML CODE HERE</div>  
    ]]></entity>

</template>

Thank you


#2

What language is active for these files?


#3

its HTML syntax highlighting


#4

Does the template engine use any other tags? Is there some online documentation about the template engine?


#5

It is Template Toolkit (Perl) but I use Cyclone 3 framework.


#6

So is it possible?

For example WebStorm works out of the box.

It just “ignore” CDATA tag


#7

It’s possible. It just requires a language package that matches for the template-specific tags and then includes the HTML grammar for everything else, like this one.


#8

I quite don’t understand that your code. Literally everything what I need is to highlight that file as HTML syntax, but if there will be <![CDATA[ just ignore it (skip).


#9

Yes, but in order to skip it, you have to have the language package highlight it. It doesn’t have to have a color (you can give it a class name that your theme doesn’t include), but it has to be matched by Atom’s grammar.


#10

So what I have to do? Because I have no skills with creating language packages.


#11

The example I’ve provided is easy enough to tweak. Or you can post a complete description of all the rules and wait until someone else has time to write one.


#12

There is no rules, I just want same syntax highlighting as HTML (copy paste) but only difference is that it should skip tag CDATA (for example it should be white color), like in that picture of Webstorm.


#13

Then why did you say that it was Template Toolkit? I looked that up and it has a bunch of rules, none of which involve a CDATA keyword.

Anyway, the language package is here. Don’t download it directly into .atom/packages. Instead, you should clone or unzip it in your project folder and use the command line instruction apm link inside the language-no-cdata folder.


#14

Thank you very much :slight_smile: