Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@wdprlib/runtime

Client-side runtime for Wikidot markup.

Installation

bun add @wdprlib/runtime

Usage

import { initWdprRuntime } from "@wdprlib/runtime";
import type { WdprRuntime, RuntimeOptions } from "@wdprlib/runtime";

// Initialize after DOM is ready
const runtime: WdprRuntime = initWdprRuntime({
  root: document.getElementById("page-content") as HTMLElement,
  onRate: async (pageId, points) => {
    const res = await fetch("/api/rate", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ page_id: pageId, points }),
    });
    return res.json();
  },
});

// Cleanup when navigating away or re-rendering
runtime.destroy();

Features

  • Tabview tab switching
  • Collapsible block toggle
  • Table of contents navigation
  • Footnote / bibliography interactions
  • Foldable list toggle
  • Math rendering (MathML with SVG polyfill via hfmath)
  • Rating module callbacks
  • Date formatting (odate)
  • Email obfuscation reveal

Related Packages

License

AGPL-3.0 - See LICENSE