import type { Node } from '../jostraca' import type { ContentProps } from './Content' import { cmp, template } from '../jostraca' /** * The props `Line` reads: exactly `Content`'s. * * An alias rather than a copy, so the two cannot drift apart. The * components are one terminator apart -- `Line` appends a newline and * renders the same way -- and the Go port says the same thing by taking * `ContentProps` in `LineP`. */ type LineProps = ContentProps const Line = cmp(function Line(props, children) { const node: Node = props.ctx$.node node.kind = 'content' node.indent = props.indent let src = null != props.arg ? props.arg : null != props.src ? props.src : 'string' === typeof children ? children : '' src += '\n' // THE SAME RENDER AS `Content`, and it was not: this passed the model // alone, so `props.replace` and `props.extra` were dropped on the // floor. A `Line` inside a `List` therefore emitted `{item.n}` // verbatim where a `Content` in the same position substituted, and // nothing said why -- the two components are a terminator apart and // nothing documented a second difference. // // THE GO PORT WAS ALREADY RIGHT: `LineP` delegates to `ContentP`, // which merges `Extra` and forwards `Replace`. So this is the case // AGENTS.md names -- the port pre-empting a latent TS bug -- and the // fix goes into TypeScript with Go left alone. // // `raw` is part of that sameness. A line of final bytes is the same // claim as a span of them, one terminator apart, and a `Line` that // templated under an option that says otherwise would be the second // undocumented difference all over again. See Content for what raw // does and why it is not the default. if (true !== props.raw) { const model = { ...props.ctx$.model, ...(props.extra || {}), } src = template(src, model, { replace: props.replace }) } node.content = src node.name = props.name }) export { Line } export type { LineProps }