-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
353 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import { parseMixed } from "@lezer/common" | ||
import { parseMixed } from "@lezer/common"; | ||
|
||
import { jsonLanguage } from "@codemirror/lang-json" | ||
import { pythonLanguage } from "@codemirror/lang-python" | ||
import { javascriptLanguage } from "@codemirror/lang-javascript" | ||
import { htmlLanguage } from "@codemirror/lang-html" | ||
import { StandardSQL } from "@codemirror/lang-sql" | ||
import { markdownLanguage } from "@codemirror/lang-markdown" | ||
import { javaLanguage } from "@codemirror/lang-java" | ||
import { lezerLanguage } from "@codemirror/lang-lezer" | ||
import { phpLanguage } from "@codemirror/lang-php" | ||
import { jsonLanguage } from "@codemirror/lang-json"; | ||
import { pythonLanguage } from "@codemirror/lang-python"; | ||
import { javascriptLanguage } from "@codemirror/lang-javascript"; | ||
import { htmlLanguage } from "@codemirror/lang-html"; | ||
import { StandardSQL } from "@codemirror/lang-sql"; | ||
import { markdownLanguage } from "@codemirror/lang-markdown"; | ||
import { javaLanguage } from "@codemirror/lang-java"; | ||
import { lezerLanguage } from "@codemirror/lang-lezer"; | ||
import { phpLanguage } from "@codemirror/lang-php"; | ||
import { elixirLanguage } from "codemirror-lang-elixir"; | ||
|
||
import { NoteContent, NoteLanguage } from "./parser.terms.js" | ||
import { LANGUAGES } from "../languages.js" | ||
|
||
const languageMapping = Object.fromEntries(LANGUAGES.map(l => [l.token, l.parser])) | ||
import { NoteContent, NoteLanguage } from "./parser.terms.js"; | ||
import { LANGUAGES } from "../languages.js"; | ||
|
||
const languageMapping = Object.fromEntries( | ||
LANGUAGES.map((l) => [l.token, l.parser]), | ||
); | ||
|
||
export function configureNesting() { | ||
return parseMixed((node, input) => { | ||
let id = node.type.id | ||
if (id == NoteContent) { | ||
let noteLang = node.node.parent.firstChild.getChildren(NoteLanguage)[0] | ||
let langName = input.read(noteLang?.from, noteLang?.to) | ||
|
||
// if the NoteContent is empty, we don't want to return a parser, since that seems to cause an | ||
// error for StreamLanguage parsers when the buffer size is large (e.g >300 kb) | ||
if (node.node.from == node.node.to) { | ||
return null | ||
} | ||
|
||
if (langName in languageMapping && languageMapping[langName] !== null) { | ||
//console.log("found parser for language:", langName) | ||
return { | ||
parser:languageMapping[langName], | ||
} | ||
} | ||
} | ||
return null | ||
}) | ||
return parseMixed((node, input) => { | ||
let id = node.type.id; | ||
if (id == NoteContent) { | ||
let noteLang = node.node.parent.firstChild.getChildren(NoteLanguage)[0]; | ||
let langName = input.read(noteLang?.from, noteLang?.to); | ||
|
||
// if the NoteContent is empty, we don't want to return a parser, since that seems to cause an | ||
// error for StreamLanguage parsers when the buffer size is large (e.g >300 kb) | ||
if (node.node.from == node.node.to) { | ||
return null; | ||
} | ||
|
||
if ( | ||
langName in languageMapping && | ||
languageMapping[langName] !== null | ||
) { | ||
//console.log("found parser for language:", langName) | ||
return { | ||
parser: languageMapping[langName], | ||
}; | ||
} | ||
} | ||
return null; | ||
}); | ||
} |
Oops, something went wrong.