blob: 9043ec03ca681509d4b42a5ab6d46e22a2d7b7e5 [file] [log] [blame]
import { Block, Tokens } from '../primitives.js';
export type Stringifier = (block: Block) => string;
function join(tokens: Tokens): string {
return (
tokens.start +
tokens.delimiter +
tokens.postDelimiter +
tokens.tag +
tokens.postTag +
tokens.type +
tokens.postType +
tokens.name +
tokens.postName +
tokens.description +
tokens.end +
tokens.lineEnd
);
}
export default function getStringifier(): Stringifier {
return (block: Block): string =>
block.source.map(({ tokens }) => join(tokens)).join('\n');
}