bdkjones / CodeKit

CodeKit 3 Issue Tracker
https://codekitapp.com
82 stars 5 forks source link

@import tag doesn't fail when path is incorrect #663

Closed lolbat closed 2 years ago

lolbat commented 3 years ago

Quick, short summary:

When importing an html file with into a .kit file the @import tag will successfully import a file but not show it in the Linked Files display if the path is incorrect. In fact it will succeed with spaces behind any of the path seperators

This path is incorrect. The Linked Files collection doesn't show it but CodeKit will successfully import the file <!-- @import / components/index_column2_component.html -->

The correct path is <!-- @import /components/index_column2_component.html -->

This path will also still succeed <!-- @import / components/ index_column2_component.html -->

Expected results: The import should have failed and raised an error

Actual results: The import succeeds

Exact steps to reproduce: Create a .kit file. Import a file and add a space after the path separator

It successfully import even for other filetypes and even with longer filepaths

bdkjones commented 2 years ago

Ah, well that's a subtle little bug. I've fixed it for the next release. Kit is a very flexible parser, so any of these are valid:

<!-- @import    some/file.txt   , "some/file.txt", 'some/file.txt', "some/file.txt -->

The import-linker treats leading and trailing whitespace as non-significant UNLESS that whitespace appears inside a set of quotes, like this:

<!-- @import " this/will/fail.txt", "so/will.this.txt " --> 

Note that in the top example, the last closing quotation marks are omitted. The file will still compile because the import linker can infer what was intended. This, however, would fail:

<!-- @import "some/file.txt, another/file.txt --> 

I looked at what other tools, such as Dart Sass, do with leading/trailing whitespace inside of quotation marks and I've adopted the same behavior.