/**
 * Micron markup → HTML renderer using the micron-parser library.
 * Reference: https://github.com/RFnexus/micron-parser-js
 */

import MicronParser from "micron-parser";

let darkParser: MicronParser | null = null;
let lightParser: MicronParser | null = null;

export function renderMicron(source: string, darkTheme: boolean = true): string {
  if (darkTheme) {
    if (!darkParser) darkParser = new MicronParser(true, true);
    return darkParser.convertMicronToHtml(source);
  } else {
    if (!lightParser) lightParser = new MicronParser(false, true);
    return lightParser.convertMicronToHtml(source);
  }
}
