Skip to content

Commit

Permalink
General Maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Mar 25, 2023
1 parent f0e9489 commit ae21175
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 80 deletions.
30 changes: 29 additions & 1 deletion dist/glimmer.cjs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ function glimmer(hljs) {
end: /"/,
contains: [
XML_ENTITIES
/* MUSTACHE_EXPRESSION added later */
]
},
{
begin: /'/,
end: /'/,
contains: [
XML_ENTITIES
/* MUSTACHE_EXPRESSION added later */
]
}
]
Expand All @@ -180,15 +182,27 @@ function glimmer(hljs) {
BLOCK_PARAMS,
THIS_EXPRESSION,
ATTRIBUTES,
// {
// className: 'variable',
// keywords: KEYWORDS,
// match: /\s[\w\d-_^]+/
// },
// {
// match: /\b[a-z][a-zA-Z0-9-]+\b/,
// keywords: KEYWORDS,
// className: 'keyword'
// },
CURLY_NAME,
STRING
// NAME,
];
const SUB_EXPRESSION = {
keywords: KEYWORDS,
begin: regex.concat(
/\(/,
regex.lookahead(
regex.concat(
// /[^)]+/,
/\)/
)
)
Expand Down Expand Up @@ -241,6 +255,7 @@ function glimmer(hljs) {
ABS_NAME
]
},
// close tag
{
className: "tag",
begin: regex.concat(/<\/:?/, regex.lookahead(regex.concat(TAG_NAME, />/))),
Expand Down Expand Up @@ -317,10 +332,21 @@ function setupTemplateTag(_hljs, js) {
const GLIMMER_TEMPLATE_TAG = {
begin: /<template>/,
end: /<\/template>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (match, response) => {
const afterMatchIndex = match[0].length + match.index;
const nextChar = match.input[afterMatchIndex];
if (nextChar === "<" || nextChar === ",") {
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
nextChar === "<" || // the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
nextChar === ","
) {
response.ignoreMatch();
return;
}
Expand All @@ -343,6 +369,8 @@ function setupTemplateTag(_hljs, js) {
variants: [
{
begin: GLIMMER_TEMPLATE_TAG.begin,
// we carefully check the opening tag to see if it truly
// is a tag and not a false positive
"on:begin": GLIMMER_TEMPLATE_TAG.isTrulyOpeningTag,
end: GLIMMER_TEMPLATE_TAG.end
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"lint": "pnpm lint:js && pnpm --filter '*' lint:js",
"lint:fix": "pnpm lint:js:fix && pnpm --filter '*' lint:js:fix"
"lint:fix": "pnpm lint:js:fix && pnpm --filter '*' lint:js:fix",
"test": "pnpm --filter '*' test"
},
"engines": {
"node": "^14 || ^16 || ^18"
Expand Down
Loading

0 comments on commit ae21175

Please sign in to comment.