// import { Util, type Context } from "../index.js" // export function HyperText(context: Context) { // const { lexicon: { content, formatting, blockQuoted }} = Util.Lexer(context); // const tags = formatting.reduce((acc, curr) => { // acc[curr.start] = [...(acc[curr.start] ?? []), `${curr.type}`] // acc[curr.end] = [...(acc[curr.end] ?? []), `/${curr.type}`] // return acc // }, {} as Record) // const queue = Object.values(tags) // const splits = [0, ...Object.keys(tags)].map((startIndex, index, arr) => { // return content.slice(parseInt(startIndex as string), parseInt(arr[index + 1] as string)); // }) // const html = splits.reduce((acc, curr) => { // acc.value += curr // const html = (queue.shift() ?? []) // while (html.length > 0) { // const item = html.shift()! // if (item?.startsWith("/")) { // if (!item.endsWith(acc.orphans[0] ?? ' ') && html.length !== 0) html.push(item) // else { // acc.orphans.shift() // acc.value += `<${item}>` // } // } else { // acc.orphans.unshift(item!) // acc.value += `<${item}>` // } // } // return acc // }, { // value: "", // orphans: [] as string[] // }).value // return ({ // html: blockQuoted ? '
' + html + '
' : html // }) // }