From d48098b006abf0e05ff8dcc3a0dbc3e401e33dce Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Wed, 5 Nov 2025 14:53:42 -0800 Subject: [PATCH] describe and inspect --- src/ribbit.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ribbit.ts b/src/ribbit.ts index 190c7a0..92df1ed 100644 --- a/src/ribbit.ts +++ b/src/ribbit.ts @@ -1,3 +1,6 @@ +import { globals } from 'shrimp' +import { AnsiUp } from 'ansi_up' + const buffer: string[] = [] const NOSPACE_TOKEN = '!!ribbit-nospace!!' const TAG_TOKEN = '!!ribbit-tag!!' @@ -22,7 +25,18 @@ export function wrapCode(code: string): string { return "ribbit do:\n " + code + "\nend" } +const ansiUp = new AnsiUp() + export const ribbitGlobals = { + // special variables + 'page-title': '🦐 shrimp', + + // html-friendly info functions + describe: (v: any) => ansiUp.ansi_to_html(globals.describe(v)), + inspect: (v: any) => ansiUp.ansi_to_html(globals.inspect(v)), + echo: (...args: any[]) => console.log(...args), + + // 🐸 ribbit: async (cb: Function) => { await cb() const output = buffer.join("\n") @@ -32,8 +46,6 @@ export const ribbitGlobals = { tag: async (tagFn: Function, atDefaults = {}) => (atNamed = {}, ...args: any[]) => tagFn(Object.assign({}, atDefaults, atNamed), ...args), nospace: () => NOSPACE_TOKEN, - echo: (...args: any[]) => console.log(...args), - 'page-title': '🦐 shrimp' } for (const name of HTML5_TAGS) {