Dependency-free WYSIWYG markdown/html editor
Go to file
gsb 86d59877f1 feat: Add macro support
New: macros.ts with MacroDef, parseBlockMacro, matchInlineMacro,
buildMacroTags, processInlineMacros.

Macro syntax:
  @user                     — bare, no args
  @user()                   — empty parens, same as bare
  @npc(Goblin King)         — self-closing with args
  @style(box center         — block: no closing paren on first line
  Content here.             — content on subsequent lines
  )                         — closing paren on its own line

Unknown macro names now render as an error:
  <span class="ribbit-error">Unknown macro: @bogus</span>

The verbatim keyword causes the contents to render as literals and also
preserves line breaks.
2026-04-29 03:03:58 +00:00
src feat: Add macro support 2026-04-29 03:03:58 +00:00
test feat: Add macro support 2026-04-29 03:03:58 +00:00
.gitignore Initial commit of ribbit library 2026-04-28 23:30:53 +00:00
LICENSE Initial commit 2026-04-28 16:21:33 -07:00
package-lock.json Initial commit of ribbit library 2026-04-28 23:30:53 +00:00
package.json Single ribbit namespace instead of window globals 2026-04-29 01:40:18 +00:00
README.md Initial commit of ribbit library 2026-04-28 23:30:53 +00:00
tsconfig.json Add themes support 2026-04-29 01:20:55 +00:00

ribbit

Zero-dependency WYSIWYG markdown editor

Files

  • src/hopdown.js — Markdown ↔ HTML converter (HopDown.toHTML(), HopDown.toMarkdown())
  • src/ribbit.js — Base viewer class (Ribbit), plugin base class (RibbitPlugin), utilities
  • src/ribbit-editor.js — Editor class (RibbitEditor) with VIEW/EDIT/WYSIWYG modes
  • src/ribbit.css — Editor and content styles

Usage

<link rel="stylesheet" href="ribbit/src/ribbit.css">
<article id="ribbit">your markdown here</article>

<script src="ribbit/src/hopdown.js"></script>
<script src="ribbit/src/ribbit.js"></script>
<script src="ribbit/src/ribbit-editor.js"></script>
<script>
    const editor = new RibbitEditor({ plugins: [] });
    editor.run();

    // Switch modes
    editor.wysiwyg();  // WYSIWYG editing
    editor.edit();      // Source editing
    editor.view();      // Read-only view

    // Get content
    editor.getMarkdown();
    editor.getHTML();
</script>

Supported Markdown

Bold, italic, inline code, links, headings (h1-h6), unordered/ordered/nested lists, blockquotes, fenced code blocks with language, horizontal rules, GFM tables with column alignment, and paragraphs. Arbitrary nesting of all inline formatting.

Tests

Open test/test_ribbit-down.html in a browser.