Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Having javascript multiline comments (/* ... */) inside the multiline string #24

Closed
yuvilio opened this issue Dec 4, 2014 · 3 comments

Comments

@yuvilio
Copy link

yuvilio commented Dec 4, 2014

Is it possible to have multiline js style comments (/*... */) in the string? One convoluted use case is having commented CDATA blocks in one's svg markup for css styles.

multiline(function(){
/*
<svg>
<style>
  /* <![CDATA[ */
    rect {
      fill: salmon;
    }
  /* ]]> */
</style>
</svg>


*/        })

That just generates an expected SyntaxError: Unexpected token < error and non of the escaping i've tried seems to generate the desired comments.

I can skip the CDATA blocks or put the styles in my separate stylesheets rather than the tag, so this is not blocking, but I was curious about it.

@sindresorhus
Copy link
Owner

No sorry. That would complicate the parser too much for such an edge-case.

@yuvilio
Copy link
Author

yuvilio commented Dec 4, 2014

Figured and makes sense.

@yuvilio
Copy link
Author

yuvilio commented Dec 13, 2014

This ended up being much easier to handle using a template engine (swig in my case) than trying to twist multiline into something it's not. I went back to using multiline for what it does best, making multiple line Javascript strings that are pleasant to look at and work with.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants