Thursday, July 10, 2014

HTML syntax: highlight text/html blocks properly

I'm working with a HTML templating engine (Knockout) where templates are embedded as <script type="text/html"> blocks; a small example file might look like the following:

<html>
<head>

<script src="jquery.js"></script>

<script type="text/html" id="my-template">
<div>Hello</div>
</script>

<script>
$(document).ready(function(){alert("Hi!")});
</script>

</head>

<body>
<h1>Test!</h1>
<div data-bind="template: 'my-template'"></div>
</body>

</html>

The issue I'm having is that the html.vim syntax file treats anything with a "<script" start as javascript:

syn region javaScript start=+<script\_[^>]*>+ ...

Instead, javascript regions should start with either

<script>

or

<script type="text/javascript">

and <script type="text/html"> should be formatted accordingly.


I've spent quite a bit of time poking around at this problem and can't seem to figure it out without modifying the actual system-level syntax file itself. Hopefully someone can advise!



dan
---
Daniel Ashbrook, Ph.D.
Samsung Research America
http://danielashbrook.com

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: