nhmood / watson-ruby

inline issue manager
MIT License
634 stars 50 forks source link

parser doesn't recognized chained file extensions such as .html.eco #240

Closed javoire closed 10 years ago

javoire commented 10 years ago

.html.eco contains <!-- comments but the parser disregards the .html.eco since it's not in the extensions array

.html.eco and .js.eco are two common eco extensions

Solution 1

'.eco'     => ['<!--','//'],            # ECO

would be a solution but the parser currently identifies the double extension as a single one:

.html.eco

and

.js.eco

instead of just

.eco

Solution 2

The parser traverses the extensions until it reaches the first one

.html.eco => .html
.js.eco => .js

Thus recognizing the extension as a normal .html or .js

I can take a look at it but which version would be preferred?

Cheers Jonatan

nhmood commented 10 years ago

@javoire I ended up implementing your Solution 2 as it seemed like the cleanest approach and other people had been asking for the same support. Sorry this took so long!

javoire commented 10 years ago

Awesome! no probs!

javoire commented 10 years ago

By the way. Does this cover the case when a html.eco file contains both html-comments

<!-- 

AND eco comments

//

at the same time? Or will it only treat it as a html-file? :)

nhmood commented 10 years ago

Currently, it will use the last filetype as the comment type i.e. myfile.html.eco will be recognized as .eco and use the // comment type associated with .eco files. If you had myfile.html.eco.js then the recognized extension would be .js and the associated comment types would be used.

There isn't any support for looking for all listed filetype comments but that might be something to add (pretty straight forward too). I want to think a little about where that might cause problems or be unwanted behavior before adding it in though, if you can think of any possible issues let me know.

javoire commented 10 years ago

Cool. Actually in my use case I'm looking for the exact opposite; the first filetype as comment type. E.g. .html.eco as .html and .js.eco as .js :)

Usually in an .html.eco file, the majority of the code is html, and likewise for the .js.eco.

However, in a js.coffee file that would be the exact opposite. (all of it is coffee)

So therefore I'd say the best solution would to actually look for all comment types in a file with multiple file endings. Yes, I'll let you know if think of anything.