-
question about how bluehawk parses comments. i have the following in a JavaScript file: //someFile.js
// :snippet-start: paginate
const PAGINATE_MOVIES = gql`
# :snippet-start: paginate-query
query PaginateMovies(
$prevTitle: String
$nextTitle: String
$limit: Int!
$sortDirection: MovieSortByInput!
) {
movies(
# Can add other query filters here if you'd like
query: { title_gt: $prevTitle, title_lt: $nextTitle }
limit: $limit
sortBy: $sortDirection
) {
_id
title
year
}
}
# :snippet-end:
`;
// ...rest of snippet
// :snippet-end: bluehawk successfully parses 2 snippets, based on this behavior, my question is: how does bluehawk identify tags?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
While there is actually a bunch of implementation for handling tokens that push another parser (such as the There's an edge case here where if a block comment open token were in a string without a matching close comment token, the Bluehawk parser would treat this as an error while the JS parser would not see the block comment at all. Some additional string-awareness might be worth adding to avoid this case. |
Beta Was this translation helpful? Give feedback.
While there is actually a bunch of implementation for handling tokens that push another parser (such as the
<?php
tag that switches from HTML to PHP), this is actually not as smart as any of that. The JS implementation doesn't declare any string types so any Bluehawk token in a string will be picked up. Your JS parser ignores the gql template literal (it's just a string as far as JS is concerned), but Bluehawk finds the tag tokens and uses them. Meanwhile, your gql parser ignores the Bluehawk tokens because they are commented out in gql.There's an edge case here where if a block comment open token were in a string without a matching close comment token, the Bluehawk parser would treat th…