@leiden-js/linter-leiden-plus
v1.1.1
Published
Basic Leiden+ linting for CodeMirror (or standalone)
Readme
@leiden-js/linter-leiden-plus
Part of leiden-js, a set of packages for working with the Leiden notation systems used in epigraphic digital editing within JavaScript environments.
Linter for Leiden+ notation, providing syntax validation and error detection for the Leiden+ epigraphic notation system.
Installation
npm install @leiden-js/linter-leiden-plusUsage
Standalone Usage
Use the linting function for server-side or custom implementations:
import {lintLeidenPlus} from "@leiden-js/linter-leiden-plus";
import {parser} from "@leiden-js/parser-leiden-plus";
const text = "example [unclosed";
const tree = parser.parse(text, {topNode: "InlineContent"});
const errors = lintLeidenPlus(text, tree);
console.log(errors);
// [{ from: 8, to: 17, severity: "error", message: "...", code: "..." }]CodeMirror Integration
For CodeMirror 6 integration, use the pre-configured extension:
import {leidenPlusLinter} from "@leiden-js/linter-leiden-plus";
import {EditorView} from "@codemirror/view";
const view = new EditorView({
extensions: [
// ... other extensions
leidenPlusLinter(),
// With custom configuration
leidenPlusLinter({
delay: 1000, // Delay before linting (ms)
autoPanel: true, // Auto-open lint panel
})
]
});API
lintLeidenPlus(doc: string, syntaxTree: Tree): LeidenDiagnostic[]
Linting function for Leiden+ text.
- doc: The document text to lint
- syntaxTree: Parsed syntax tree from
@leiden-js/parser-leiden-plus - Returns: Array of diagnostic objects with error locations and messages, and unique error codes for programmatic handling and testing
leidenPlusLinter(config?: LintConfig): Extension
CodeMirror extension that integrates the linter.
- config: Optional CodeMirror lint configuration
- Returns: CodeMirror extension
Related Packages
@leiden-js/parser-leiden-plus- Required parser@leiden-js/codemirror-leiden-plus- Complete set of editor extensions with linting included
