Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix improper tokenization of script tags #90

Closed
wants to merge 75 commits into from
Closed

Conversation

winstliu
Copy link
Contributor

The main part of this fix is instead of trying to capture the ending > of <script> in the patterns block, we now explicitly capture it in beginCaptures. To keep the tag tokenization (of things like id) from breaking, I moved all the 'include': '#tag-stuff' parts into beginCaptures as well. Same thing goes for endCaptures and the </ of </script>. In general all that's left in patterns is the embedded language.

Also, I didn't see what (?:\\s*\\n)? had to do with anything, so I removed it.

Fixes #82

/cc @benogle, @mnquintana

expect(tokens[0][6]).toEqual value: 'id', scopes: ['text.html.basic', 'meta.attribute-with-value.id.html', 'string.quoted.double.html', 'meta.toc-list.id.html']
expect(tokens[0][7]).toEqual value: '"', scopes: ['text.html.basic', 'meta.attribute-with-value.id.html', 'string.quoted.double.html', 'punctuation.definition.string.end.html']
expect(tokens[0][9]).toEqual value: 'type', scopes: ['text.html.basic', 'entity.other.attribute-name.html']
expect(tokens[0][10]).toEqual value: '=', scopes: ['text.html.basic']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems suspicious, but it should be a simple fix in a different PR 😄.

@winstliu
Copy link
Contributor Author

Blocked on #140, atom/language-javascript#438.

@winstliu winstliu added blocked and removed blocked labels Oct 24, 2016
@winstliu
Copy link
Contributor Author

I don't want too many specs to be broken at the same time so I'll wait until 1.13 reaches stable to merge this.

redbassett and others added 14 commits September 16, 2017 23:58
I recently wrote a package called
[atom-grammar-test](https://www.npmjs.com/package/atom-grammar-test)
that allows writing grammar tests inline in your example files.
Inspired by [ST3's Syntax
Test](https://www.sublimetext.com/docs/3/syntax.html#Testing), it
greatly helps writing complex cases since you're just annotating inline
in your code examples.

I included two examples for HTML to showcase usability, a base case as well as one for
template fragments that was the most recent improvement to support
angular templates.  It's much easier to write a regression in this grammar test format
compared to either writing jasmine style expects or relying on visual
inspection.
Fixes parsing files with CRLF line endings
@winstliu
Copy link
Contributor Author

Whoops. Will close and reopen.

@winstliu winstliu closed this Sep 16, 2017
@winstliu winstliu deleted the wl-fix-script-tags branch September 16, 2017 22:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embedded scripts handled poorly