Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ Wikidot markup parser and renderer.

| Package | Description |
|---------|-------------|
| [@wdpr/ast](./packages/ast) | AST type definitions |
| [@wdpr/parser](./packages/parser) | Wikidot markup parser |
| [@wdpr/render](./packages/render) | HTML renderer |
| [@wdpr/runtime](./packages/runtime) | Client-side runtime for interactive elements |
| [@wdprlib/ast](./packages/ast) | AST type definitions |
| [@wdprlib/parser](./packages/parser) | Wikidot markup parser |
| [@wdprlib/render](./packages/render) | HTML renderer |
| [@wdprlib/runtime](./packages/runtime) | Client-side runtime for interactive elements |

## Installation

```bash
npm install @wdpr/parser @wdpr/render
npm install @wdprlib/parser @wdprlib/render
```

## Usage

```ts
import { parse } from '@wdpr/parser'
import { renderToHtml } from '@wdpr/render'
import { parse } from '@wdprlib/parser'
import { renderToHtml } from '@wdprlib/render'

const ast = parse('**Hello** world')
const html = renderToHtml(ast)
Expand Down
30 changes: 15 additions & 15 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bunup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineWorkspace([
dts: true,
minify: false,
clean: true,
external: ["@wdpr/ast"],
external: ["@wdprlib/ast"],
},
},
{
Expand All @@ -33,7 +33,7 @@ export default defineWorkspace([
dts: true,
minify: false,
clean: true,
external: ["@wdpr/ast"],
external: ["@wdprlib/ast"],
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/wdmock-cf/apps/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"typecheck": "bunx tsc --noEmit"
},
"dependencies": {
"@wdpr/runtime": "workspace:*"
"@wdprlib/runtime": "workspace:*"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250123.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/wdmock-cf/apps/files/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* - /common--javascript/html-block-iframe.js - Resize script for iframe
*/

import { HTML_BLOCK_RESIZE_SCRIPT } from "@wdpr/runtime";
import { HTML_BLOCK_RESIZE_SCRIPT } from "@wdprlib/runtime";

interface Env {
FILES: R2Bucket;
Expand Down
6 changes: 3 additions & 3 deletions examples/wdmock-cf/apps/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"dependencies": {
"@wdmock/db": "workspace:*",
"@wdmock/shared": "workspace:*",
"@wdpr/parser": "workspace:*",
"@wdpr/render": "workspace:*",
"@wdpr/runtime": "workspace:*",
"@wdprlib/parser": "workspace:*",
"@wdprlib/render": "workspace:*",
"@wdprlib/runtime": "workspace:*",
"hono": "^4.7.5"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions examples/wdmock-cf/apps/main/src/client/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initWdprRuntime, type WdprRuntime } from "@wdpr/runtime";
import { initWdprRuntime, type WdprRuntime } from "@wdprlib/runtime";

let runtime: WdprRuntime | null = null;
let currentPageId: number | null = null;
Expand All @@ -21,7 +21,7 @@ function applyPageStyles(styles: string[]) {

/**
* Safely set HTML content using a sandboxed approach.
* The HTML is generated server-side by @wdpr/render which sanitizes user input.
* The HTML is generated server-side by @wdprlib/render which sanitizes user input.
* We use a template element for parsing to avoid script execution during parsing.
*/
function setTrustedHtml(element: Element, html: string): void {
Expand Down Expand Up @@ -76,7 +76,7 @@ async function loadPage(path: string) {
const content = document.getElementById("page-content");
if (!content) return;

// Server-generated HTML from @wdpr/render (sanitized)
// Server-generated HTML from @wdprlib/render (sanitized)
setTrustedHtml(content, data.html);
content.dataset.pageId = String(data.page_id);

Expand Down Expand Up @@ -341,7 +341,7 @@ async function previewPage() {
h3.textContent = "Preview";
const previewContent = document.createElement("div");
previewContent.className = "preview-content";
// Server-generated HTML from @wdpr/render (sanitized)
// Server-generated HTML from @wdprlib/render (sanitized)
setTrustedHtml(previewContent, data.html);
previewArea.appendChild(h3);
previewArea.appendChild(previewContent);
Expand Down Expand Up @@ -391,7 +391,7 @@ async function loadNavigation() {
const actionsSection = sidebar.querySelector("#side-bar-actions");
// Clone the actions section to preserve it after replaceChildren
const actionsClone = actionsSection?.cloneNode(true) as HTMLElement | null;
// Server-generated HTML from @wdpr/render (sanitized)
// Server-generated HTML from @wdprlib/render (sanitized)
setTrustedHtml(sidebar, html);
// Re-add actions section at the beginning
if (actionsClone) {
Expand All @@ -407,7 +407,7 @@ async function loadNavigation() {
const { html, styles } = (await topbarRes.json()) as { html: string; styles?: string[] };
const topbar = document.getElementById("top-bar");
if (topbar) {
// Server-generated HTML from @wdpr/render (sanitized)
// Server-generated HTML from @wdprlib/render (sanitized)
setTrustedHtml(topbar, html);
}
if (styles) navStyles.push(...styles);
Expand Down
8 changes: 4 additions & 4 deletions examples/wdmock-cf/apps/main/src/services/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*
* Handles source parsing, module resolution, and HTML rendering.
*/
import { parse, extractDataRequirements, resolveModules, resolveIncludes } from "@wdpr/parser";
import { parse, extractDataRequirements, resolveModules, resolveIncludes } from "@wdprlib/parser";
import type {
NormalizedListPagesQuery,
ListPagesExternalData,
PageData,
PageRef,
} from "@wdpr/parser";
import { renderToHtml } from "@wdpr/render";
import type { PageContext } from "@wdpr/render";
} from "@wdprlib/parser";
import { renderToHtml } from "@wdprlib/render";
import type { PageContext } from "@wdprlib/render";
import { SITE, getUserInfo, parseFullname, buildFullname } from "@wdmock/shared";
import { getTagsByFullname, rowToPageData, getAllPageSources } from "@wdmock/db";

Expand Down
2 changes: 1 addition & 1 deletion examples/wdmock-cf/packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@wdmock/shared": "workspace:*",
"@wdpr/parser": "workspace:*"
"@wdprlib/parser": "workspace:*"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250123.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/wdmock-cf/packages/db/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pages table operations
*/

import type { PageData } from "@wdpr/parser";
import type { PageData } from "@wdprlib/parser";
import { getUserInfo, buildFullname } from "@wdmock/shared";

export interface PageApiData {
Expand Down
6 changes: 3 additions & 3 deletions examples/wdmock-cf/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ This is an example application demonstrating the capabilities of the wdpr librar

* **Server**: Hono on Cloudflare Workers
* **Database**: Cloudflare D1 (SQLite)
* **Parser**: @wdpr/parser
* **Renderer**: @wdpr/render
* **Runtime**: @wdpr/runtime (client-side)
* **Parser**: @wdprlib/parser
* **Renderer**: @wdprlib/render
* **Runtime**: @wdprlib/runtime (client-side)
', 1);
INSERT OR REPLACE INTO pages (site_id, category, unix_name, title, source, owner_user_id) VALUES (1, '_default', 'scp-280-jp', 'SCP-280-JP', '[[include credit:start]]
**タイトル:** SCP-280-JP - 縮小する時空間異常
Expand Down
2 changes: 1 addition & 1 deletion packages/ast/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @wdpr/ast
# @wdprlib/ast

## 1.0.0

Expand Down
4 changes: 2 additions & 2 deletions packages/ast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wdpr/ast",
"version": "1.0.0",
"name": "@wdprlib/ast",
"version": "0.1.0",
"description": "AST types for Wikidot markup",
"keywords": [
"ast",
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @wdpr/parser
# @wdprlib/parser

## 1.0.0

Expand All @@ -9,4 +9,4 @@
### Patch Changes

- Updated dependencies [[`5e5a7de`](https://github.com/r74tech/wdpr/commit/5e5a7def04c116fdf90419684b5c773716ca4ed4)]:
- @wdpr/ast@1.0.0
- @wdprlib/ast@1.0.0
6 changes: 3 additions & 3 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wdpr/parser",
"version": "1.0.0",
"name": "@wdprlib/parser",
"version": "0.1.0",
"description": "Parser for Wikidot markup",
"keywords": [
"ast",
Expand Down Expand Up @@ -39,6 +39,6 @@
},
"dependencies": {
"@braintree/sanitize-url": "^7.1.1",
"@wdpr/ast": "workspace:*"
"@wdprlib/ast": "workspace:*"
}
}
6 changes: 3 additions & 3 deletions packages/parser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Re-export AST types and utilities from @wdpr/ast
// Re-export AST types and utilities from @wdprlib/ast
export type {
Position,
Point,
Expand Down Expand Up @@ -36,7 +36,7 @@ export type {
DateItem,
Embed,
TocEntry,
} from "@wdpr/ast";
} from "@wdprlib/ast";
export {
createPoint,
createPosition,
Expand All @@ -52,7 +52,7 @@ export {
list,
listItemElements,
listItemSubList,
} from "@wdpr/ast";
} from "@wdprlib/ast";

// Lexer
export type { TokenType, Token, LexerOptions } from "./lexer";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/lexer/lexer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPoint, createPosition } from "@wdpr/ast";
import { createPoint, createPosition } from "@wdprlib/ast";
import { createToken, type Token, type TokenType } from "./tokens";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/lexer/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Position } from "@wdpr/ast";
import type { Position } from "@wdprlib/ast";

/**
* Token types for Wikidot markup
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/parse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../lexer";
import { tokenize } from "../lexer";
import { preprocess } from "./preprocess";
import type { Element, SyntaxTree } from "@wdpr/ast";
import type { Element, SyntaxTree } from "@wdprlib/ast";
import { blockRules, blockFallbackRule, inlineRules, type ParseContext } from "./rules";
import { canApplyBlockRule } from "./rules/block/utils";
import { mergeSpanStripParagraphs, cleanInternalFlags } from "./postprocess";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/postprocess/spanStrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Handles span_ (paragraph strip) paragraph merging
*/
import type { Element, ContainerData } from "@wdpr/ast";
import type { Element, ContainerData } from "@wdprlib/ast";

/**
* Check if an element is a container with specific type
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/rules/block/align.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Element } from "@wdpr/ast";
import type { Element } from "@wdprlib/ast";
import type { BlockRule, ParseContext, RuleResult } from "../types";
import { currentToken } from "../types";
import { parseBlocksUntil } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/rules/block/block-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Element, ListData, ListItem } from "@wdpr/ast";
import type { Element, ListData, ListItem } from "@wdprlib/ast";
import type { BlockRule, ParseContext, RuleResult } from "../types";
import { currentToken } from "../types";
import { parseBlockName, parseAttributes, canApplyBlockRule } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/rules/block/blockquote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Element } from "@wdpr/ast";
import type { Element } from "@wdprlib/ast";
import type { BlockRule, ParseContext, RuleResult } from "../types";
import { currentToken } from "../types";
import { parseInlineUntil } from "../inline/utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/rules/block/center.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Creates a centered paragraph.
* Requires: line start + = + space + text
*/
import type { Element } from "@wdpr/ast";
import type { Element } from "@wdprlib/ast";
import type { BlockRule, ParseContext, RuleResult } from "../types";
import { currentToken } from "../types";
import { parseInlineUntil } from "../inline/utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/rules/block/clear-float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* Note: ~~~ (3 tildes) does NOT work in Wikidot - requires 4+
*/
import type { Element } from "@wdpr/ast";
import type { Element } from "@wdprlib/ast";
import type { BlockRule, ParseContext, RuleResult } from "../types";
import { currentToken } from "../types";

Expand Down
Loading