import type { VisualInkLine } from "@a-morphous/frontispiece-ink-processor/types" import { marked } from "marked" import { html } from "./bootstrap" import { parseLineIntoTokens } from "@a-morphous/frontispiece-line-parser" import "./tag-classes.css" type LineViewerProps = { line: VisualInkLine } export const LineViewer = (props: LineViewerProps) => { const renderTokens = () => { let str = "" let tokens = parseLineIntoTokens(props.line.text) if (!tokens) { str = props.line.text } else { for (let t of tokens) { switch (t.type) { case "text": str += t.text break case "tag": if (t.isClosingTag) { str += `` } else { str += `` } break case "link": case "note": // we'll implement this later str += t.text break } } } const parsedMarkdown = marked.parseInline(str, { gfm: true, }) return html`` } const classes: string[] = [] if (props.line.isHidden) { classes.push("logbook") } return html`

${renderTokens()} ${props.line.path}

` }