pull/87/head
Zef Hemel 2022-10-03 15:43:36 +00:00
parent 8ef9e955ba
commit 8ddd61f029
6 changed files with 45 additions and 43 deletions

16
mod.ts
View File

@ -1,5 +1,3 @@
import React from "https://esm.sh/v96/@types/react@~17.0/index.d.ts";
export { export {
autocompletion, autocompletion,
completionKeymap, completionKeymap,
@ -7,6 +5,7 @@ export {
export { export {
defaultHighlightStyle, defaultHighlightStyle,
Language,
syntaxHighlighting, syntaxHighlighting,
syntaxTree, syntaxTree,
} from "https://esm.sh/@codemirror/language@6.2.1?external=@codemirror/state"; } from "https://esm.sh/@codemirror/language@6.2.1?external=@codemirror/state";
@ -22,6 +21,19 @@ export {
closeBracketsKeymap, closeBracketsKeymap,
} from "https://esm.sh/@codemirror/autocomplete@6.3.0?external=@codemirror/state"; } from "https://esm.sh/@codemirror/autocomplete@6.3.0?external=@codemirror/state";
export { styleTags, Tag, tags } from "https://esm.sh/@lezer/highlight";
export type {
BlockContext,
LeafBlock,
LeafBlockParser,
MarkdownConfig,
Table,
TaskList,
} from "https://esm.sh/@lezer/markdown";
export type { SyntaxNode } from "https://esm.sh/@lezer/common";
export { export {
searchKeymap, searchKeymap,
} from "https://esm.sh/@codemirror/search?external=@codemirror/state"; } from "https://esm.sh/@codemirror/search?external=@codemirror/state";

View File

@ -1,4 +1,4 @@
import { Tag } from "@lezer/highlight"; import { Tag } from "../../mod.ts";
export const WikiLinkTag = Tag.define(); export const WikiLinkTag = Tag.define();
export const WikiLinkPageTag = Tag.define(); export const WikiLinkPageTag = Tag.define();

View File

@ -1,17 +1,18 @@
import * as plugos from "@plugos/plugos/types"; import * as plugos from "../plugos/types.ts";
import { EndpointHookT } from "@plugos/plugos/hooks/endpoint"; import { EndpointHookT } from "../plugos/hooks/endpoint.ts";
import { CronHookT } from "@plugos/plugos/hooks/node_cron"; import { CronHookT } from "../plugos/hooks/node_cron.ts";
import { EventHookT } from "@plugos/plugos/hooks/event"; import { EventHookT } from "../plugos/hooks/event.ts";
import { CommandHookT } from "@silverbulletmd/web/hooks/command"; import { CommandHookT } from "../web/hooks/command.ts";
import { SlashCommandHookT } from "@silverbulletmd/web/hooks/slash_command"; import { SlashCommandHookT } from "../web/hooks/slash_command.ts";
import { PageNamespaceHookT } from "../server/hooks/page_namespace"; import { PageNamespaceHookT } from "../server/hooks/page_namespace.ts";
export type SilverBulletHooks = CommandHookT & export type SilverBulletHooks =
SlashCommandHookT & & CommandHookT
EndpointHookT & & SlashCommandHookT
CronHookT & & EndpointHookT
EventHookT & & CronHookT
PageNamespaceHookT; & EventHookT
& PageNamespaceHookT;
export type SyntaxExtensions = { export type SyntaxExtensions = {
syntax?: { [key: string]: NodeDef }; syntax?: { [key: string]: NodeDef };

View File

@ -1,7 +1,7 @@
import { Tag } from "@lezer/highlight"; import { Tag } from "../../mod.ts";
import type { MarkdownConfig } from "@lezer/markdown"; import type { MarkdownConfig } from "../../mod.ts";
import { System } from "@plugos/plugos/system"; import { System } from "../plugos/system.ts";
import { Manifest } from "@silverbulletmd/common/manifest"; import { Manifest } from "./manifest.ts";
export type MDExt = { export type MDExt = {
// unicode char code for efficiency .charCodeAt(0) // unicode char code for efficiency .charCodeAt(0)

View File

@ -1,11 +1,11 @@
import type { SyntaxNode } from "@lezer/common"; import type { SyntaxNode } from "../../mod.ts";
import type { Language } from "@codemirror/language"; import type { Language } from "../../mod.ts";
import { ParseTree } from "./tree"; import { ParseTree } from "./tree.ts";
export function lezerToParseTree( export function lezerToParseTree(
text: string, text: string,
n: SyntaxNode, n: SyntaxNode,
offset = 0 offset = 0,
): ParseTree { ): ParseTree {
let children: ParseTree[] = []; let children: ParseTree[] = [];
let nodeText: string | undefined; let nodeText: string | undefined;

View File

@ -1,31 +1,20 @@
import { styleTags, tags as t } from "@lezer/highlight"; import { styleTags, tags as t } from "../../mod.ts";
import { import {
BlockContext, BlockContext,
LeafBlock, LeafBlock,
LeafBlockParser, LeafBlockParser,
MarkdownConfig, MarkdownConfig,
parseCode,
Table, Table,
TaskList, TaskList,
} from "@lezer/markdown"; } from "../../mod.ts";
import { markdown } from "./markdown"; import { markdown } from "./markdown/index.ts";
import * as ct from "./customtags"; import * as ct from "./customtags.ts";
import { import { Language } from "../../mod.ts";
Language,
LanguageDescription,
LanguageSupport,
} from "@codemirror/language";
import { StreamLanguage } from "@codemirror/language";
import { yaml } from "@codemirror/legacy-modes/mode/yaml";
import {
javascriptLanguage,
typescriptLanguage,
} from "@codemirror/lang-javascript";
import { import {
MDExt, MDExt,
mdExtensionStyleTags, mdExtensionStyleTags,
mdExtensionSyntaxConfig, mdExtensionSyntaxConfig,
} from "./markdown_ext"; } from "./markdown_ext.ts";
export const pageLinkRegex = /^\[\[([^\]]+)\]\]/; export const pageLinkRegex = /^\[\[([^\]]+)\]\]/;
@ -45,7 +34,7 @@ const WikiLink: MarkdownConfig = {
return cx.addElement( return cx.addElement(
cx.elt("WikiLink", pos, pos + match[0].length, [ cx.elt("WikiLink", pos, pos + match[0].length, [
cx.elt("WikiLinkPage", pos + 2, pos + match[0].length - 2), cx.elt("WikiLinkPage", pos + 2, pos + match[0].length - 2),
]) ]),
); );
}, },
after: "Emphasis", after: "Emphasis",
@ -89,7 +78,7 @@ class CommentParser implements LeafBlockParser {
cx.elt("Comment", leaf.start, leaf.start + leaf.content.length, [ cx.elt("Comment", leaf.start, leaf.start + leaf.content.length, [
// cx.elt("CommentMarker", leaf.start, leaf.start + 3), // cx.elt("CommentMarker", leaf.start, leaf.start + 3),
...cx.parser.parseInline(leaf.content.slice(3), leaf.start + 3), ...cx.parser.parseInline(leaf.content.slice(3), leaf.start + 3),
]) ]),
); );
return true; return true;
} }