sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[Scala] HTML tags highlighted as invalid #2427

Closed rchl closed 4 years ago

rchl commented 4 years ago

Some HTML tags are highlighted as invalid in this messy but hopefully correct template:

@partials.base("Foo")("asb")(views.html.modules.contentMeta.generic()) {
    @if(action.getErrorCode() != "100" && action.getErrorCode() != "102" && action.getErrorCode() != "104") {
        @if(!sth.equals(Messages.get("yyy")) && !sth.equals(Messages.get("yyy"))) {
            @if(lll != null || ddd != null) {
                @if(lll == null || ddd == null) {
                    <div class="abc remove-overflow">
                    } else {
                    <div class="abc">
                    }
                @if(lll != null) {
                    @if(ddd == null) {
                        <div class="uuu-wrapper remove-float">
                        } else {
                        <div class="uuu-wrapper">
                        }
                    <div class="uuu">
                        <div class="uuu-content">
                            <h2>@tit</h2>
                            <p>@lll</p>
                            @if(las == null) {
                                <img class="yy-activated" src="/assets/images/icons/success-icon-big.png">
                            } else {
                                <a href="@hlink" class="clickspinner"><span class="btn">@Messages.get(las)</span></a>
                            }
                        </div>
                    </div>
                    @if(las == null) {
                        <div class="yy-minor-actions">
                            <a href="/@cc/xas/opy" class="center cancel-yy" class="clickspinner">@Messages.get("yyy")</a>
                            <span class="divider"> | </span>
                            @if(canS) {
                                <a href="/@cc/xas/yy/cancel" class="center cancel-yy clickspinner">@Messages.get("yyy")</a>
                            }
                        </div>
                    }
                </div>
                }
                @if(ddd != null) {
                    @if(lll == null) {
                        <div class="uuu-wrapper second-uuu remove-float">
                        } else {
                        <div class="yy-YL-wrapper second-l-YL">
                        }
                    <div class="l-YL">
                        <div class="l-YL-content">
                            <h2>@pBT</h2>
                            <p>@ddd</p>
                            @if(pBB == null) {
                                <img class="l-activated" src="/assets/images/icons/success-icon-big.png">
                            } else {
                                @if(pBox != null) {
                                    @if(pBox.equalsIgnoreCase(Constants.IPL)) {
                                        <a><span class="btn btn-disabled">@Messages.get(pBB)
                                            PEN</span></a>
                                        <br>
                                        <a href="@Constants.SOME()/@cc.toLowerCase()/asb/l/x/Y/@uwcid" class="clickspinner" style="color: #000;
                                            cursor: pointer;
                                            margin-top: 10px;
                                            display: inline-block;">@Messages.get("yyy")</a>
                                    } else {
                                        <a href="@pBox" class="clickspinner"><span class="btn">@Messages.get(pBB)</span></a>
                                    }
                                }
                            }
                        </div>
                    </div>
                    @if(pBB == null) {
                        <div class="l-minor-actions">
                            <a href="/@cc/asb/opy" class="center cancel-l clickspinner">@Messages.get("yyy")</a>
                            @if(canS) {
                                <span class="divider"> | </span>
                                <a href="/@cc/asb/l/cancel" class="center cancel-l clickspinner">@Messages.get("yyy")</a>
                            }
                        </div>
                    }
                </div>
                }
            </div>
                <div class="get-help">
                    <a target="_blank" href="https://a.b.c/hc/en-us/x/123-X-Types">
                        @Messages.get("page.generic.get_help")
                    </a>
                </div>
            }
        }
    }
}
Screenshot 2020-07-22 at 11 02 45
rchl commented 4 years ago

I've also tried with current master branch of scala syntax (pictured on the screenshot) but it seems to have no impact on this issue.

djspiewak commented 4 years ago

I think the problem are the {/} pairs used by the template. I'm actually not certain that this is correct syntax, but I admit that it's immensely difficult for me to puzzle it out. Does scalac actually parse this? If so, is there an identifiable semantic which causes it to not treat the {/} template pairs as being XML-mode escapes?

rchl commented 4 years ago

We have an app that uses those exact templates (unobfuscated of course) and they work. But not sure what is used exactly to parse those. I can ask for more details if you want :)

rchl commented 4 years ago

It's used in a Java Play framework (https://www.playframework.com/documentation/2.8.x/ScalaTemplates#The-template-engine). So maybe it's not scala but just based on Scala as the text says there?

rchl commented 4 years ago

That's how I understand it so I'll close this issue. It doesn't seem like anyone made syntax for the Twirl templating language which is shame. :)