Refactoring about how proxy fetching happens
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Tag } from "../deps.ts";
|
||||
import type { MarkdownConfig } from "../deps.ts";
|
||||
import { System } from "../../plugos/system.ts";
|
||||
import { Manifest } from "../manifest.ts";
|
||||
import { Manifest, NodeDef } from "../manifest.ts";
|
||||
|
||||
export type MDExt = {
|
||||
// unicode char code for efficiency .charCodeAt(0)
|
||||
@@ -9,7 +9,7 @@ export type MDExt = {
|
||||
regex: RegExp;
|
||||
nodeType: string;
|
||||
tag: Tag;
|
||||
styles: { [key: string]: string };
|
||||
styles?: { [key: string]: string };
|
||||
className?: string;
|
||||
};
|
||||
|
||||
@@ -53,16 +53,20 @@ export function loadMarkdownExtensions(system: System<any>): MDExt[] {
|
||||
const manifest = plug.manifest as Manifest;
|
||||
if (manifest.syntax) {
|
||||
for (const [nodeType, def] of Object.entries(manifest.syntax)) {
|
||||
mdExtensions.push({
|
||||
nodeType,
|
||||
tag: Tag.define(),
|
||||
firstCharCodes: def.firstCharacters.map((ch) => ch.charCodeAt(0)),
|
||||
regex: new RegExp("^" + def.regex),
|
||||
styles: def.styles,
|
||||
className: def.className,
|
||||
});
|
||||
mdExtensions.push(nodeDefToMDExt(nodeType, def));
|
||||
}
|
||||
}
|
||||
}
|
||||
return mdExtensions;
|
||||
}
|
||||
|
||||
export function nodeDefToMDExt(nodeType: string, def: NodeDef): MDExt {
|
||||
return {
|
||||
nodeType,
|
||||
tag: Tag.define(),
|
||||
firstCharCodes: def.firstCharacters.map((ch) => ch.charCodeAt(0)),
|
||||
regex: new RegExp("^" + def.regex),
|
||||
styles: def.styles,
|
||||
className: def.className,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user