0

I have elements that contain various things. Some contain HTML; web-mode does not realize that so it messes up the indentation. Some contain CSS; same issue.

My first preference is, can I somehow tell web-mode what language is inside each element? (I can mechanically intuit from the attributes. I can do light Emacs hacking.

My second preference is, can I somehow tell web-mode just to not mess with any formatting inside a element? At least then, after I manually get it formatted right, web-mode won't clobber it.

<html>
    <head>
    </head>
    <body>
        <script type="text/x-LP5">
        <!-- need to tell web-mode this is HTML; otherwise it has no clue and indents like thi: -->
        <!doctype html>
        <html lang="en">
        <head>
        <meta charset="utf-8">
        <title>LP5 bootstrap</title>
        <style>
        @<LP5_GlobalCSS@>
        </style>
        </head>
        <body>
        @<LP5_1@>
        </body>
        </html>
        </script>
    </body>
</html>
3
  • If you can give some concrete examples, it might help people give you more concrete answers.
    – Stefan
    Nov 14, 2017 at 2:39
  • Not sure what part's unclear, but OK.
    – Ron Burk
    Nov 14, 2017 at 2:57
  • E.g. I don't know when web-mode "messes" in undesirable ways. But based on your example, I think you might like to start with a bug report to the web-mode maintainer telling it that web-mode should be cautious when inside a <script> whose type is not recognized.
    – Stefan
    Nov 14, 2017 at 14:18

1 Answer 1

0

Finally found the place (web-mode-scan-elements) in the source where it decides what mode to apply to a <script> element contents. It doesn't seem to allow for any hooks for custom types, but I think I can apply a patch there unless a better option appears.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.