Materialized query parser + data indexing and querying
This commit is contained in:
@@ -11,7 +11,7 @@ syntax:
|
||||
regex: "@[A-Za-z\\.]+"
|
||||
styles:
|
||||
color: blue
|
||||
URL:
|
||||
NakedURL:
|
||||
firstCharacters:
|
||||
- "h"
|
||||
regex: "https?:\\/\\/[-a-zA-Z0-9@:%._\\+~#=]{1,256}([-a-zA-Z0-9()@:%_\\+.~#?&=\\/]*)"
|
||||
|
||||
+8
-5
@@ -3,11 +3,14 @@ import { whiteOutQueries } from "../query/materialized_queries";
|
||||
|
||||
import { batchSet } from "plugos-silverbullet-syscall/index";
|
||||
import { parseMarkdown } from "plugos-silverbullet-syscall/markdown";
|
||||
import { collectNodesMatching, ParseTree, renderToText } from "../../common/tree";
|
||||
import { collectNodesOfType, ParseTree, renderToText } from "../../common/tree";
|
||||
|
||||
type Item = {
|
||||
item: string;
|
||||
export type Item = {
|
||||
name: string;
|
||||
nested?: string;
|
||||
// Not stored in DB
|
||||
page?: string;
|
||||
pos?: number;
|
||||
};
|
||||
|
||||
export async function indexItems({ name, text }: IndexEvent) {
|
||||
@@ -17,7 +20,7 @@ export async function indexItems({ name, text }: IndexEvent) {
|
||||
console.log("Indexing items", name);
|
||||
let mdTree = await parseMarkdown(text);
|
||||
|
||||
let coll = collectNodesMatching(mdTree, (n) => n.type === "ListItem");
|
||||
let coll = collectNodesOfType(mdTree, "ListItem");
|
||||
|
||||
coll.forEach((n) => {
|
||||
if (!n.children) {
|
||||
@@ -34,7 +37,7 @@ export async function indexItems({ name, text }: IndexEvent) {
|
||||
}
|
||||
let item = textNodes.map(renderToText).join("").trim();
|
||||
let value: Item = {
|
||||
item,
|
||||
name: item,
|
||||
};
|
||||
if (nested) {
|
||||
value.nested = nested;
|
||||
|
||||
@@ -20,6 +20,7 @@ async function actionClickOrActionEnter(mdTree: ParseTree | null) {
|
||||
await navigateTo(pageLink, +pos);
|
||||
break;
|
||||
case "URL":
|
||||
case "NakedURL":
|
||||
await openUrl(mdTree.children![0].text!);
|
||||
break;
|
||||
case "Link":
|
||||
|
||||
Reference in New Issue
Block a user