Something went wrong. Try again.
Logiverse library. (beta)
Something went wrong. Try again.
1.3 kB · 45 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546// 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<string, string[]>)
// 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 ? '<blockquote>' + html + '</blockquote>' : html// })// }