Skip to content

Commit af728bd

Browse files
committed
Implements #1556
Massive code restructure
1 parent aac5e0c commit af728bd

38 files changed

+30
-28
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Run build
2424
run: |
2525
deno task build-production
26+
deno task build-plug-compile
2627
- name: Publish to JSR
2728
run: deno publish --allow-dirty
2829
- name: Release
@@ -33,3 +34,4 @@ jobs:
3334
draft: false
3435
files: |
3536
website/CHANGELOG.md
37+
dist/plug-compile.js

.github/workflows/server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/setup-go@v4
2121
with:
2222
go-version: "1.25.1"
23-
- name: Compile frontend and plug-compile with Deno
23+
- name: Compile client and plug-compile with Deno
2424
run: |
2525
deno task build-production
2626
deno task build-plug-compile

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test:
2828
# Run frontend tests
2929
deno task test
3030
# Run backend tests
31-
go test ./pkg/...
31+
go test ./server/...
3232

3333
generate:
3434
# Regenerate the Lua parser from the the grammar

client/cm_plugins/clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function cleanModePlugins(client: Client) {
2121
luaDirectivePlugin(client),
2222
cleanWikiLinkPlugin(client),
2323
hashtagPlugin(),
24-
frontmatterPlugin(client),
24+
frontmatterPlugin(client),
2525
];
2626

2727
if (client.ui.viewState.uiOptions.markdownSyntaxRendering) {

client/cm_plugins/wiki_link.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { processWikiLink, type WikiLinkMatch } from "./wiki_link_processor.ts";
1212
export function cleanWikiLinkPlugin(client: Client) {
1313
return decoratorStateField((state) => {
1414
const widgets: any[] = [];
15-
15+
1616
syntaxTree(state).iterate({
1717
enter: ({ type, from, to }) => {
1818
if (type.name !== "WikiLink") {
@@ -46,7 +46,9 @@ export function cleanWikiLinkPlugin(client: Client) {
4646
if (e.altKey) {
4747
// Move cursor into the link
4848
client.editorView.dispatch({
49-
selection: { anchor: from + wikiLinkMatch.leadingTrivia.length },
49+
selection: {
50+
anchor: from + wikiLinkMatch.leadingTrivia.length,
51+
},
5052
});
5153
client.focus();
5254
return;

client/cm_plugins/wiki_link_processor.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
21
import type { EditorState } from "@codemirror/state";
32
import { Decoration } from "@codemirror/view";
43
import type { Client } from "../client.ts";
5-
import { fileName, isBuiltinPath } from "@silverbulletmd/silverbullet/lib/resolve";
4+
import {
5+
fileName,
6+
isBuiltinPath,
7+
} from "@silverbulletmd/silverbullet/lib/resolve";
68
import {
79
encodePageURI,
810
encodeRef,
@@ -30,9 +32,10 @@ export interface WikiLinkProcessorOptions {
3032
}
3133

3234
export function processWikiLink(options: WikiLinkProcessorOptions): any[] {
33-
const { from, to, match, matchFrom, matchTo, client, state, callback } = options;
35+
const { from, to, match, matchFrom, matchTo, client, state, callback } =
36+
options;
3437
const widgets: any[] = [];
35-
38+
3639
const { leadingTrivia, stringRef, alias, trailingTrivia } = match;
3740
const ref = parseToRef(stringRef);
3841

@@ -43,7 +46,9 @@ export function processWikiLink(options: WikiLinkProcessorOptions): any[] {
4346
} else if (ref.path === "" || isBuiltinPath(ref.path)) {
4447
linkStatus = "default";
4548
} else if (
46-
Array.from(client.clientSystem.allKnownFiles).some((file) => file === ref.path)
49+
Array.from(client.clientSystem.allKnownFiles).some((file) =>
50+
file === ref.path
51+
)
4752
) {
4853
linkStatus = "default";
4954
} else if (client.fullSyncCompleted || client.clientSystem.knownFilesLoaded) {
@@ -57,7 +62,7 @@ export function processWikiLink(options: WikiLinkProcessorOptions): any[] {
5762
}[linkStatus];
5863

5964
const renderingSyntax = client.ui.viewState.uiOptions.markdownSyntaxRendering;
60-
65+
6166
if (isCursorInRange(state, [from, to]) || renderingSyntax) {
6267
// Only attach a CSS class, then get out
6368
if (linkStatus !== "default") {

client/markdown_parser/constants.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ export const wikiLinkRegex =
33
export const mdLinkRegex = /!?\[(?<title>[^\]]*)\]\((?<url>.+)\)/g;
44
export const tagRegex =
55
/#(?:(?:\d*[^\d\s!@#$%^&*(),.?":{}|<>\\][^\s!@#$%^&*(),.?":{}|<>\\]*)|(?:<[^>\n]+>))/;
6-
export const nakedUrlRegex=
6+
export const nakedUrlRegex =
77
/(^https?:\/\/([-a-zA-Z0-9@:%_\+~#=]|(?:[.](?!(\s|$)))){1,256})(([-a-zA-Z0-9(@:%_\+~#?&=\/]|(?:[.,:;)](?!(\s|$))))*)/;
8-
export const frontmatterUrlRegex=
9-
/"(https?:\/\/[^\s"']+)"/g;
8+
export const frontmatterUrlRegex = /"(https?:\/\/[^\s"']+)"/g;
109
export const frontmatterWikiLinkRegex =
1110
/"(?<leadingTrivia>!?\[\[)(?<stringRef>.*?)(?:\|(?<alias>.*?))?(?<trailingTrivia>\]\])"/g;
1211
export const pWikiLinkRegex = new RegExp("^" + wikiLinkRegex.source); // Modified regex used only in parser

client/markdown_parser/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as ct from "./customtags.ts";
1313
import { NakedURLTag } from "./customtags.ts";
1414
import { TaskList } from "./extended_task.ts";
1515
import { Table } from "./table_parser.ts";
16-
import {nakedUrlRegex, pWikiLinkRegex, tagRegex} from "./constants.ts";
16+
import { nakedUrlRegex, pWikiLinkRegex, tagRegex } from "./constants.ts";
1717
import { parse } from "./parse_tree.ts";
1818
import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
1919
import { luaLanguage } from "../../lib/space_lua/parse.ts";
@@ -291,7 +291,7 @@ function regexParser({
291291
const NakedURL = regexParser(
292292
{
293293
firstCharCode: 104, // h
294-
regex:new RegExp(`^${nakedUrlRegex.source}`),
294+
regex: new RegExp(`^${nakedUrlRegex.source}`),
295295
nodeType: "NakedURL",
296296
className: "sb-naked-url",
297297
tag: NakedURLTag,

client/styles/theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,4 @@ html[data-markdown-syntax-rendering="on"] {
358358

359359
--admonition-icon: url('data:image/svg+xml,<svg width="16" height="16" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>');
360360
--admonition-color: #00c853;
361-
}
361+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ require (
88
github.com/go-chi/chi/v5 v5.2.3
99
github.com/go-chi/render v1.0.3
1010
github.com/golang-jwt/jwt/v5 v5.3.0
11+
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a
1112
github.com/spf13/cobra v1.10.1
1213
github.com/stretchr/testify v1.11.1
1314
)
1415

1516
require (
1617
github.com/ajg/form v1.5.1 // indirect
1718
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a // indirect
1919
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2020
github.com/pmezard/go-difflib v1.0.0 // indirect
2121
github.com/spf13/pflag v1.0.9 // indirect

0 commit comments

Comments
 (0)