Skip to content

Commit

Permalink
lxlquery prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperengstrom committed Nov 14, 2024
1 parent d678d20 commit 732b8d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/codemirror-lang-lxlquery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"test": "vitest",
"prepare": "cd ../../ && husky && cd ./packages/codemirror-lang-lxlquery && rollup -c",
"lint": "eslint . && prettier --check .",
"lint": "eslint . && prettier --check .",
"format": "prettier --write ."
},
"lint-staged": {
Expand Down
35 changes: 18 additions & 17 deletions packages/codemirror-lang-lxlquery/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ const customTags = {
BooleanQuery: Tag.define('BooleanQuery'),
BooleanOperator: Tag.define('BooleanOperator'),
Wildcard: Tag.define('Wildcard')
}
};

export const lxlQueryLanguage = LRLanguage.define({
name: 'Libris XL query',
parser: parser.configure({
props: [
styleTags(customTags)
]
props: [styleTags(customTags)]
}),
languageData: {}
});
Expand All @@ -28,20 +26,23 @@ export function lxlQuery() {
return new LanguageSupport(lxlQueryLanguage);
}

const highlighter = tagHighlighter([
{ tag: customTags.Qualifier, class: 'qualifier' },
{ tag: customTags.QualifierKey, class: 'qualifier-key' },
{ tag: customTags.QualifierValue, class: 'qualifier-value' },
{ tag: customTags.EqualOperator, class: 'equal-operator' },
{ tag: customTags.CompareOperator, class: 'compare-operator' },
{ tag: customTags.BooleanOperator, class: 'boolean-operator' },
{ tag: customTags.BooleanQuery, class: 'boolean-query' },
{ tag: customTags.Wildcard, class: 'wildcard' }
], {
all: 'lxlq',
})
const highlighter = tagHighlighter(
[
{ tag: customTags.Qualifier, class: 'qualifier' },
{ tag: customTags.QualifierKey, class: 'qualifier-key' },
{ tag: customTags.QualifierValue, class: 'qualifier-value' },
{ tag: customTags.EqualOperator, class: 'equal-operator' },
{ tag: customTags.CompareOperator, class: 'compare-operator' },
{ tag: customTags.BooleanOperator, class: 'boolean-operator' },
{ tag: customTags.BooleanQuery, class: 'boolean-query' },
{ tag: customTags.Wildcard, class: 'wildcard' }
],
{
all: 'lxlq'
}
);

/**
* CM editor extension that adds CSS classes for lxlquery nodes
*/
export const highlighterExtension = syntaxHighlighting(highlighter)
export const highlighterExtension = syntaxHighlighting(highlighter);
5 changes: 4 additions & 1 deletion packages/codemirror-lang-lxlquery/test/grammar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ for (const file of fs.readdirSync(caseDir)) {
const name = /^[^.]*/.exec(file)?.[0];
if (name) {
describe(name, () => {
for (const { name, run } of fileTests(fs.readFileSync(path.join(caseDir, file), 'utf8'), file))
for (const { name, run } of fileTests(
fs.readFileSync(path.join(caseDir, file), 'utf8'),
file
))
it(name, () => run(lxlQueryLanguage.parser));
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/codemirror-lang-lxlquery/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['**/*.{test,spec}.{js,ts}']
}
test: {
include: ['**/*.{test,spec}.{js,ts}']
}
});

0 comments on commit 732b8d0

Please sign in to comment.